Skip to content

Commit

Permalink
ntb: fix possible NULL dereference
Browse files Browse the repository at this point in the history
kmalloc can fail and we should check for NULL before using the pointer
returned by kmalloc.

Signed-off-by: Sudip Mukherjee <[email protected]>
Acked-by: Dave Jiang <[email protected]>
Signed-off-by: Jon Mason <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and jonmason committed Mar 18, 2016
1 parent ee5f750 commit 2572c7f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/ntb/test/ntb_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2572c7f

Please sign in to comment.