提交 9b3a6549 编写于 作者: J Julia Lawall 提交者: Linus Torvalds

drivers/scsi/ses.c: eliminate double free

The few lines below the kfree of hdr_buf may go to the label err_free
which will also free hdr_buf.  The most straightforward solution seems to
be to just move the kfree of hdr_buf after these gotos.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@r@
identifier E;
expression E1;
iterator I;
statement S;
@@

*kfree(E);
... when != E = E1
    when != I(E,...) S
    when != &E
*kfree(E);
// </smpl>
Signed-off-by: NJulia Lawall <julia@diku.dk>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: <stable@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2d30a1f6
...@@ -595,8 +595,6 @@ static int ses_intf_add(struct device *cdev, ...@@ -595,8 +595,6 @@ static int ses_intf_add(struct device *cdev,
ses_dev->page10_len = len; ses_dev->page10_len = len;
buf = NULL; buf = NULL;
} }
kfree(hdr_buf);
scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL);
if (!scomp) if (!scomp)
goto err_free; goto err_free;
...@@ -608,6 +606,8 @@ static int ses_intf_add(struct device *cdev, ...@@ -608,6 +606,8 @@ static int ses_intf_add(struct device *cdev,
goto err_free; goto err_free;
} }
kfree(hdr_buf);
edev->scratch = ses_dev; edev->scratch = ses_dev;
for (i = 0; i < components; i++) for (i = 0; i < components; i++)
edev->component[i].scratch = scomp + i; edev->component[i].scratch = scomp + i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册