* [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack
@ 2013-02-22 6:07 Kumar Amit Mehta
2013-02-22 6:26 ` Dan Carpenter
2013-02-22 10:02 ` Ian Abbott
0 siblings, 2 replies; 5+ messages in thread
From: Kumar Amit Mehta @ 2013-02-22 6:07 UTC (permalink / raw)
To: abbotti
Cc: fmhess, gregkh, hsweeten, dan.carpenter, devel, linux-kernel,
kernel-janitors
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@gmail.com>
---
drivers/staging/comedi/drivers/usbduxsigma.c | 27 ++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index dc6b017..9e99a4b 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -681,7 +681,11 @@ 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;
+
+ local_transfer_buffer = kmalloc(16, GFP_KERNEL);
+ if (!local_transfer_buffer)
+ return -ENOMEM;
/* 7f92 to zero */
local_transfer_buffer[0] = 0;
@@ -702,19 +706,22 @@ static int usbduxsub_start(struct usbduxsub *usbduxsub)
1,
/* Timeout */
BULK_TIMEOUT);
- if (errcode < 0) {
+ if (errcode < 0)
dev_err(&usbduxsub->interface->dev,
"comedi_: control msg failed (start)\n");
- return errcode;
- }
- return 0;
+
+ kfree(local_transfer_buffer);
+ return errcode;
}
static int usbduxsub_stop(struct usbduxsub *usbduxsub)
{
int errcode = 0;
+ uint8_t *local_transfer_buffer;
- uint8_t local_transfer_buffer[16];
+ local_transfer_buffer = kmalloc(16, GFP_KERNEL);
+ if (!local_transfer_buffer)
+ return -ENOMEM;
/* 7f92 to one */
local_transfer_buffer[0] = 1;
@@ -732,12 +739,12 @@ static int usbduxsub_stop(struct usbduxsub *usbduxsub)
1,
/* Timeout */
BULK_TIMEOUT);
- if (errcode < 0) {
+ if (errcode < 0)
dev_err(&usbduxsub->interface->dev,
"comedi_: control msg failed (stop)\n");
- return errcode;
- }
- return 0;
+
+ kfree(local_transfer_buffer);
+ return errcode;
}
static int usbduxsub_upload(struct usbduxsub *usbduxsub,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack
2013-02-22 6:07 [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack Kumar Amit Mehta
@ 2013-02-22 6:26 ` Dan Carpenter
2013-02-22 10:02 ` Ian Abbott
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2013-02-22 6:26 UTC (permalink / raw)
To: Kumar Amit Mehta
Cc: abbotti, devel, fmhess, gregkh, kernel-janitors, linux-kernel
Looks good.
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack
2013-02-22 6:07 [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack Kumar Amit Mehta
2013-02-22 6:26 ` Dan Carpenter
@ 2013-02-22 10:02 ` Ian Abbott
2013-02-22 14:26 ` Kumar amit mehta
1 sibling, 1 reply; 5+ messages in thread
From: Ian Abbott @ 2013-02-22 10:02 UTC (permalink / raw)
To: Kumar Amit Mehta
Cc: Ian Abbott, fmhess@users.sourceforge.net,
gregkh@linuxfoundation.org, hsweeten@visionengravers.com,
dan.carpenter@oracle.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
On 2013-02-22 06:07, 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.
>
Looks good here too.
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Would you mind doing the same for usbdux.c and usbduxfast.c?
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack
2013-02-22 10:02 ` Ian Abbott
@ 2013-02-22 14:26 ` Kumar amit mehta
2013-02-22 15:36 ` Ian Abbott
0 siblings, 1 reply; 5+ messages in thread
From: Kumar amit mehta @ 2013-02-22 14:26 UTC (permalink / raw)
To: Ian Abbott
Cc: gregkh, fmhess, hsweeten, dan.carpenter, devel, linux-kernel,
kernel-janitors
On Fri, Feb 22, 2013 at 10:02:44AM +0000, Ian Abbott wrote:
> On 2013-02-22 06:07, 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.
> >
>
> Looks good here too.
>
> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
>
> Would you mind doing the same for usbdux.c and usbduxfast.c?
Sure.
As pointed out by Dan, Do you really want the buffer to be of 16 bytes, as we
are using only the first byte and passing the length as '1' in:
usbduxsub_start, usbduxsub_stop, usbduxfastsub_start, usbduxfastsub_stop ?
~Amit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack
2013-02-22 14:26 ` Kumar amit mehta
@ 2013-02-22 15:36 ` Ian Abbott
0 siblings, 0 replies; 5+ messages in thread
From: Ian Abbott @ 2013-02-22 15:36 UTC (permalink / raw)
To: Kumar amit mehta
Cc: Ian Abbott, gregkh@linuxfoundation.org,
fmhess@users.sourceforge.net, hsweeten@visionengravers.com,
dan.carpenter@oracle.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
On 2013-02-22 14:26, Kumar amit mehta wrote:
> On Fri, Feb 22, 2013 at 10:02:44AM +0000, Ian Abbott wrote:
>> On 2013-02-22 06:07, 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.
>>>
>>
>> Looks good here too.
>>
>> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
>>
>> Would you mind doing the same for usbdux.c and usbduxfast.c?
> Sure.
> As pointed out by Dan, Do you really want the buffer to be of 16 bytes, as we
> are using only the first byte and passing the length as '1' in:
> usbduxsub_start, usbduxsub_stop, usbduxfastsub_start, usbduxfastsub_stop ?
A buffer size of 1 should be fine.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-22 15:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-22 6:07 [PATCH v2] staging: comedi: drivers: usbduxsigma.c: fix DMA buffers on stack Kumar Amit Mehta
2013-02-22 6:26 ` Dan Carpenter
2013-02-22 10:02 ` Ian Abbott
2013-02-22 14:26 ` Kumar amit mehta
2013-02-22 15:36 ` Ian Abbott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox