提交 b42939aa 编写于 作者: S Suresh Thiagarajan 提交者: Christoph Hellwig

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: NViswas G <Viswas.G@pmcs.com>
Signed-off-by: NSuresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Reviewed-by: NTomas Henzl <thenzl@redhat.com>
Acked-by: NJack Wang <xjtuwjp@gmail.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
上级 f259d9bd
......@@ -395,6 +395,8 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev,
payload.offset = 0;
payload.length = 4096;
payload.func_specific = kzalloc(4096, GFP_KERNEL);
if (!payload.func_specific)
return -ENOMEM;
PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
wait_for_completion(&completion);
virt_addr = pm8001_ha->memoryMap.region[NVMD].virt_ptr;
......@@ -402,6 +404,7 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev,
bios_index++)
str += sprintf(str, "%c",
*((u8 *)((u8 *)virt_addr+bios_index)));
kfree(payload.func_specific);
return str - buf;
}
static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册