summaryrefslogtreecommitdiff
path: root/drivers/ntb
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2016-03-10 17:51:11 +0530
committerJon Mason <jdmason@kudzu.us>2016-03-17 20:52:15 -0400
commit2572c7fb4e4b941af9a0206ac8093d362ae6d371 (patch)
tree108abf8ced1b14f933e9415f48df1dbb99c2bac6 /drivers/ntb
parentee5f750f1c9d675028ecedc5439b7171f6647cb8 (diff)
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>
Diffstat (limited to 'drivers/ntb')
-rw-r--r--drivers/ntb/test/ntb_perf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index f798beb01ac6..cf19ff07680d 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -550,6 +550,8 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
return 0;
buf = kmalloc(64, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
out_offset = snprintf(buf, 64, "%d\n", perf->run);
ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
kfree(buf);