lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20130221184755.GG9138@mwanda>
Date:	Thu, 21 Feb 2013 21:47:55 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Kumar Amit Mehta <gmate.amit@...il.com>
Cc:	abbotti@....co.uk, devel@...verdev.osuosl.org,
	fmhess@...rs.sourceforge.net, gregkh@...uxfoundation.org,
	kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers
 on stack

A couple small style issues.

On Thu, Feb 21, 2013 at 09:47:06AM -0800, Kumar Amit Mehta wrote:
> This patch fixes an instance of DMA buffer on stack(being passed to
> usb_control_msg)for the USB-DUXsigma Board driver. Found using smatch.
> 
> Signed-off-by: Kumar Amit Mehta <gmate.amit@...il.com>
> ---
>  drivers/staging/comedi/drivers/usbduxsigma.c |   37 +++++++++++++++++---------
>  1 file changed, 24 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
> index dc6b017..46137e8 100644
> --- a/drivers/staging/comedi/drivers/usbduxsigma.c
> +++ b/drivers/staging/comedi/drivers/usbduxsigma.c
> @@ -681,10 +681,14 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
>  static int usbduxsub_start(struct usbduxsub *usbduxsub)
>  {
>  	int errcode = 0;
> -	uint8_t local_transfer_buffer[16];
> -
> +	uint8_t *local_transfer_buffer;

Put a blank line here between the declaration and the code.

> +	local_transfer_buffer = kmalloc(16, GFP_KERNEL);
> +	if (!local_transfer_buffer) {
> +		errcode = -ENOMEM;
> +		goto exit;

Just return directly.

> +	}
>  	/* 7f92 to zero */
> -	local_transfer_buffer[0] = 0;
> +	*local_transfer_buffer = 0;

The original is sort of nicer.  local_transfer is an array and we're
setting the first element.  It seems more clear to me.  Also I
already had to argue with everyone to get comedi to use arrays
instead of pointer math.  :P

I wonder why we have a 16 byte array when we only use the first
byte and we pass 1 as the length to usb_control_msg().  Odd.
Perhaps it shouldn't be an array after all.

regards,
dan carpenter
>  static int usbduxsub_stop(struct usbduxsub *usbduxsub)
>  {
>  	int errcode = 0;
>  

Delete this blank line...

> -	uint8_t local_transfer_buffer[16];
> +	uint8_t *local_transfer_buffer;
> +	local_transfer_buffer = kmalloc(16, GFP_KERNEL);
> +	if (!local_transfer_buffer) {
> +		errcode = -ENOMEM;
> +		goto exit;
> +	}
>  

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ