aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/csiostor
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-12-26 15:31:51 -0500
committerJames Bottomley <JBottomley@Parallels.com>2013-01-29 18:48:50 -0500
commit02db3db5aaa1154a748a7cba93e9f0098ad62f78 (patch)
treeb927c5f2bbb73b670a51180076327a16e5418e22 /drivers/scsi/csiostor
parent2b82d825a5fc94c79e7d2a7c54b0cb2d22817cc0 (diff)
[SCSI] csiostor: Don't leak mem or fail to release firmware in csio_hw_flash_config()
If kzalloc() or csio_hw_check_fwconfig() fail we may leave the csio_hw_flash_config() function without freeing allocated memory or firmware. This should take care of the leaks. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Acked-by: Naresh Kumar Inna <naresh@chelsio.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/csiostor')
-rw-r--r--drivers/scsi/csiostor/csio_hw.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 8ecdb94a59f4..bdd78fb4fc70 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -2131,13 +2131,16 @@ csio_hw_flash_config(struct csio_hw *hw, u32 *fw_cfg_param, char *path)
2131 value_to_add = 4 - (cf->size % 4); 2131 value_to_add = 4 - (cf->size % 4);
2132 2132
2133 cfg_data = kzalloc(cf->size+value_to_add, GFP_KERNEL); 2133 cfg_data = kzalloc(cf->size+value_to_add, GFP_KERNEL);
2134 if (cfg_data == NULL) 2134 if (cfg_data == NULL) {
2135 return -ENOMEM; 2135 ret = -ENOMEM;
2136 goto leave;
2137 }
2136 2138
2137 memcpy((void *)cfg_data, (const void *)cf->data, cf->size); 2139 memcpy((void *)cfg_data, (const void *)cf->data, cf->size);
2138 2140 if (csio_hw_check_fwconfig(hw, fw_cfg_param) != 0) {
2139 if (csio_hw_check_fwconfig(hw, fw_cfg_param) != 0) 2141 ret = -EINVAL;
2140 return -EINVAL; 2142 goto leave;
2143 }
2141 2144
2142 mtype = FW_PARAMS_PARAM_Y_GET(*fw_cfg_param); 2145 mtype = FW_PARAMS_PARAM_Y_GET(*fw_cfg_param);
2143 maddr = FW_PARAMS_PARAM_Z_GET(*fw_cfg_param) << 16; 2146 maddr = FW_PARAMS_PARAM_Z_GET(*fw_cfg_param) << 16;
@@ -2149,9 +2152,9 @@ csio_hw_flash_config(struct csio_hw *hw, u32 *fw_cfg_param, char *path)
2149 strncpy(path, "/lib/firmware/" CSIO_CF_FNAME, 64); 2152 strncpy(path, "/lib/firmware/" CSIO_CF_FNAME, 64);
2150 } 2153 }
2151 2154
2155leave:
2152 kfree(cfg_data); 2156 kfree(cfg_data);
2153 release_firmware(cf); 2157 release_firmware(cf);
2154
2155 return ret; 2158 return ret;
2156} 2159}
2157 2160