Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355253

Re: [PATCH] ntb: fix possible NULL dereference

From "Jiang, Dave" <dave.jiang@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] ntb: fix possible NULL dereference
Date 2016-03-10 17:30 +0100
Message-ID <rbbDl-1c2-17@gated-at.bofh.it> (permalink)
References <rb7T3-6WL-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 2016-03-10 at 17:51 +0530, Sudip Mukherjee wrote:
> 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>

Thanks!

> ---
>  drivers/ntb/test/ntb_perf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/ntb/test/ntb_perf.c
> b/drivers/ntb/test/ntb_perf.c
> index c8a37ba..b21e647 100644
> --- a/drivers/ntb/test/ntb_perf.c
> +++ b/drivers/ntb/test/ntb_perf.c
> @@ -541,6 +541,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);

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] ntb: fix possible NULL dereference Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-03-10 13:30 +0100
  Re: [PATCH] ntb: fix possible NULL dereference "Jiang, Dave" <dave.jiang@intel.com> - 2016-03-10 17:30 +0100

csiph-web