From: Julia Lawall Date: Sat, 15 May 2010 09:46:36 +0000 (+0200) Subject: HID: picolcd: Eliminate use after free X-Git-Tag: v2.6.35-rc1~454^2~1^3 X-Git-Url: http://bbs.cooldavid.org/git/?a=commitdiff_plain;h=aeacb6fd30c800e8229905eac7023777a472d772;p=net-next-2.6.git HID: picolcd: Eliminate use after free The skip label frees resp, which has not been allocated at the point of this goto and then does a break, based on the fact that err is non-zero. This is replaced by a break directly. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @free@ expression E; position p; @@ kfree@p(E) @@ expression free.E, subE<=free.E, E1; position free.p; @@ kfree@p(E) ... ( subE = E1 | * E ) // Signed-off-by: Julia Lawall Signed-off-by: Jiri Kosina --- diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c index 95253b31054..7aabf65c48e 100644 --- a/drivers/hid/hid-picolcd.c +++ b/drivers/hid/hid-picolcd.c @@ -1616,7 +1616,7 @@ static ssize_t _picolcd_flash_write(struct picolcd_data *data, int report_id, raw_data[len_off] = s > 32 ? 32 : s; if (copy_from_user(raw_data+len_off+1, u, raw_data[len_off])) { err = -EFAULT; - goto skip; + break; } resp = picolcd_send_and_wait(data->hdev, report_id, raw_data, len_off+1+raw_data[len_off]);