diff options
author | Julia Lawall <julia@diku.dk> | 2010-03-10 18:20:42 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-01 19:01:08 -0400 |
commit | 997c7813cedb9829ef8973c8ed35ecba486925ac (patch) | |
tree | ccb2dc69680ded70eba1cc597d78e7ccf2faccfe | |
parent | dbdafe5ccf02d6a59e412ac8314a030ec703e880 (diff) |
drivers/scsi/ses.c: eliminate double free
commit 9b3a6549b2602ca30f58715a0071e29f9898cae9 upstream.
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: Julia Lawall <julia@diku.dk>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/scsi/ses.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 55b034b72708..3c8a0248ea45 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -591,8 +591,6 @@ static int ses_intf_add(struct device *cdev, | |||
591 | ses_dev->page10_len = len; | 591 | ses_dev->page10_len = len; |
592 | buf = NULL; | 592 | buf = NULL; |
593 | } | 593 | } |
594 | kfree(hdr_buf); | ||
595 | |||
596 | scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); | 594 | scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); |
597 | if (!scomp) | 595 | if (!scomp) |
598 | goto err_free; | 596 | goto err_free; |
@@ -604,6 +602,8 @@ static int ses_intf_add(struct device *cdev, | |||
604 | goto err_free; | 602 | goto err_free; |
605 | } | 603 | } |
606 | 604 | ||
605 | kfree(hdr_buf); | ||
606 | |||
607 | edev->scratch = ses_dev; | 607 | edev->scratch = ses_dev; |
608 | for (i = 0; i < components; i++) | 608 | for (i = 0; i < components; i++) |
609 | edev->component[i].scratch = scomp + i; | 609 | edev->component[i].scratch = scomp + i; |