diff options
author | Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com> | 2014-05-09 02:01:01 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-05-19 13:12:26 -0400 |
commit | b42939aa075cc45ceb16c18f3b91a36bacbe7813 (patch) | |
tree | 570cdc1dfce6bb340bab051b5cb92a61ce7fddaa /drivers/scsi/pm8001/pm8001_ctl.c | |
parent | f259d9bdd2fb13926dd16ffacd3417d610c23e8c (diff) |
pm80xx : Fix missing NULL pointer checks and memory leaks
Checking return value for the memory allocattion and freeing it
while exiting the function
Signed-off-by: Viswas G <Viswas.G@pmcs.com>
Signed-off-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Acked-by: Jack Wang <xjtuwjp@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/pm8001/pm8001_ctl.c')
-rw-r--r-- | drivers/scsi/pm8001/pm8001_ctl.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 28b4e8139153..fe5eee4d0a11 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c | |||
@@ -395,6 +395,8 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev, | |||
395 | payload.offset = 0; | 395 | payload.offset = 0; |
396 | payload.length = 4096; | 396 | payload.length = 4096; |
397 | payload.func_specific = kzalloc(4096, GFP_KERNEL); | 397 | payload.func_specific = kzalloc(4096, GFP_KERNEL); |
398 | if (!payload.func_specific) | ||
399 | return -ENOMEM; | ||
398 | PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); | 400 | PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); |
399 | wait_for_completion(&completion); | 401 | wait_for_completion(&completion); |
400 | virt_addr = pm8001_ha->memoryMap.region[NVMD].virt_ptr; | 402 | virt_addr = pm8001_ha->memoryMap.region[NVMD].virt_ptr; |
@@ -402,6 +404,7 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev, | |||
402 | bios_index++) | 404 | bios_index++) |
403 | str += sprintf(str, "%c", | 405 | str += sprintf(str, "%c", |
404 | *((u8 *)((u8 *)virt_addr+bios_index))); | 406 | *((u8 *)((u8 *)virt_addr+bios_index))); |
407 | kfree(payload.func_specific); | ||
405 | return str - buf; | 408 | return str - buf; |
406 | } | 409 | } |
407 | static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL); | 410 | static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL); |