Skip to content

Commit 2572c7f

Browse files
sudipm-mukherjeejonmason
authored andcommitted
ntb: fix possible NULL dereference
kmalloc can fail and we should check for NULL before using the pointer returned by kmalloc. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Acked-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
1 parent ee5f750 commit 2572c7f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/ntb/test/ntb_perf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
550550
return 0;
551551

552552
buf = kmalloc(64, GFP_KERNEL);
553+
if (!buf)
554+
return -ENOMEM;
553555
out_offset = snprintf(buf, 64, "%d\n", perf->run);
554556
ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
555557
kfree(buf);

0 commit comments

Comments
 (0)