diff options
author | Julia Lawall <julia@diku.dk> | 2011-08-08 07:17:58 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-08-23 18:20:53 -0400 |
commit | e5969d55743c49dfca24e165a534cf5f2638e86b (patch) | |
tree | 6b56282c04fb166c6ecc32fd3d7cc8b9e7f30e1e /drivers/staging/bcm/nvm.c | |
parent | 1dc634772b0daead0e841b9034e88b6c76a05709 (diff) |
drivers/staging/bcm/nvm.c: add missing kfree
Buff is only used as a temporary buffer within the function, so it should
be freed before leaving the function in an error case.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@exists@
local idexpression x;
statement S,S1;
expression E;
identifier fl;
expression *ptr != NULL;
@@
x = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
when != if (...) { <+...kfree(x)...+> }
when any
when != true x == NULL
x->fl
...>
(
if (x == NULL) S1
|
if (...) { ... when != x
when forall
(
return \(0\|<+...x...+>\|ptr\);
|
* return ...;
)
}
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/bcm/nvm.c')
-rw-r--r-- | drivers/staging/bcm/nvm.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index 4da5b7b54a1..3de0daf5edb 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c | |||
@@ -4013,7 +4013,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | |||
4013 | if(uiTotalDataToCopy < ISOLength) | 4013 | if(uiTotalDataToCopy < ISOLength) |
4014 | { | 4014 | { |
4015 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); | 4015 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); |
4016 | return STATUS_FAILURE; | 4016 | Status = STATUS_FAILURE; |
4017 | goto out; | ||
4017 | } | 4018 | } |
4018 | 4019 | ||
4019 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - | 4020 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - |
@@ -4026,7 +4027,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | |||
4026 | if(uiTotalDataToCopy < ISOLength) | 4027 | if(uiTotalDataToCopy < ISOLength) |
4027 | { | 4028 | { |
4028 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); | 4029 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); |
4029 | return STATUS_FAILURE; | 4030 | Status = STATUS_FAILURE; |
4031 | goto out; | ||
4030 | } | 4032 | } |
4031 | 4033 | ||
4032 | uiTotalDataToCopy = ISOLength; | 4034 | uiTotalDataToCopy = ISOLength; |
@@ -4143,7 +4145,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | |||
4143 | if(uiTotalDataToCopy < ISOLength) | 4145 | if(uiTotalDataToCopy < ISOLength) |
4144 | { | 4146 | { |
4145 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); | 4147 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); |
4146 | return STATUS_FAILURE; | 4148 | Status = STATUS_FAILURE; |
4149 | goto out; | ||
4147 | } | 4150 | } |
4148 | 4151 | ||
4149 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - | 4152 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - |
@@ -4156,7 +4159,8 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | |||
4156 | if(uiTotalDataToCopy < ISOLength) | 4159 | if(uiTotalDataToCopy < ISOLength) |
4157 | { | 4160 | { |
4158 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); | 4161 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); |
4159 | return STATUS_FAILURE; | 4162 | Status = STATUS_FAILURE; |
4163 | goto out; | ||
4160 | } | 4164 | } |
4161 | 4165 | ||
4162 | uiTotalDataToCopy = ISOLength; | 4166 | uiTotalDataToCopy = ISOLength; |
@@ -4257,6 +4261,7 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | |||
4257 | 4261 | ||
4258 | } | 4262 | } |
4259 | 4263 | ||
4264 | out: | ||
4260 | kfree(Buff); | 4265 | kfree(Buff); |
4261 | 4266 | ||
4262 | return Status; | 4267 | return Status; |