From: Sudip Mukherjee Date: Thu, 10 Mar 2016 12:21:11 +0000 (+0530) Subject: ntb: fix possible NULL dereference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2572c7fb4e4b941af9a0206ac8093d362ae6d371;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Acked-by: Dave Jiang Signed-off-by: Jon Mason --- 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);