linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] p54usb: Remove DMA buffer from stack
@ 2009-11-12  0:02 Larry Finger
  2009-11-12  9:51 ` Christian Lamparter
  0 siblings, 1 reply; 3+ messages in thread
From: Larry Finger @ 2009-11-12  0:02 UTC (permalink / raw)
  To: John W Linville, chunkeey; +Cc: linux-wireless

On 2.6.32-rc6 from wireless-testing, the following warning is emitted:

------------[ cut here ]------------ 
WARNING: at lib/dma-debug.c:860 check_for_stack+0xaa/0xe0() 
Hardware name: HP Pavilion dv2700 Notebook PC 
ehci_hcd 0000:00:02.1: DMA-API: device driver maps memory fromstack
	 [addr=ffff8800b6e2bca8] 
Modules linked in: <Removed> 
Pid: 16378, comm: modprobe Not tainted 2.6.32-rc6-wl #244 
Call Trace: 
 [<ffffffff81049698>] warn_slowpath_common+0x78/0xb0 
 [<ffffffff8104972c>] warn_slowpath_fmt+0x3c/0x40 
 [<ffffffff811ae52a>] check_for_stack+0xaa/0xe0 
 [<ffffffff811afc8d>] debug_dma_map_page+0xfd/0x170 
 [<ffffffffa006297a>] usb_hcd_submit_urb+0x3da/0x9c0 [usbcore] 
 [<ffffffff81076e6f>] ? lockdep_init_map+0x5f/0x5d0 
 [<ffffffffa0063365>] usb_submit_urb+0xe5/0x260 [usbcore] 
 [<ffffffffa0064b7e>] usb_start_wait_urb+0x5e/0xf0 [usbcore] 
 [<ffffffffa0063943>] ? usb_init_urb+0x23/0x40 [usbcore] 
 [<ffffffffa0064cd4>] usb_bulk_msg+0xc4/0x150 [usbcore] 
 [<ffffffffa0441a91>] T.719+0x31/0x40 [p54usb] 
 [<ffffffffa0441acf>] p54u_upload_firmware_3887+0x2f/0x490 [p54usb] 
 [<ffffffffa049c667>] ? p54_parse_firmware+0x427/0x450 [p54common] 
 <Rest of traceback removed>
---[ end trace f77df0316ddad3de ]--- 

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@vger.org>
---

John,

This is 2.6.32 material. Sorry to find it so late in the rc cycle. I hop
DaveM doesn't give you too much trouble.

V2 - Fix line wraps in trace back.

Larry
---

Index: wireless-testing/drivers/net/wireless/p54/p54usb.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/p54/p54usb.c
+++ wireless-testing/drivers/net/wireless/p54/p54usb.c
@@ -426,12 +426,16 @@ static const char p54u_romboot_3887[] =
 static int p54u_firmware_reset_3887(struct ieee80211_hw *dev)
 {
 	struct p54u_priv *priv = dev->priv;
-	u8 buf[4];
+	u8 *buf;
 	int ret;
 
-	memcpy(&buf, p54u_romboot_3887, sizeof(buf));
+	buf = kmalloc(4, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+ 	memcpy(buf, p54u_romboot_3887, 4);
 	ret = p54u_bulk_msg(priv, P54U_PIPE_DATA,
-			    buf, sizeof(buf));
+			    buf, 4);
+	kfree(buf);
 	if (ret)
 		dev_err(&priv->udev->dev, "(p54usb) unable to jump to "
 			"boot ROM (%d)!\n", ret);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] p54usb: Remove DMA buffer from stack
  2009-11-12  0:02 [PATCH V2] p54usb: Remove DMA buffer from stack Larry Finger
@ 2009-11-12  9:51 ` Christian Lamparter
  2009-11-12 16:27   ` Larry Finger
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Lamparter @ 2009-11-12  9:51 UTC (permalink / raw)
  To: Larry Finger; +Cc: John W Linville, linux-wireless

On Thursday 12 November 2009 01:02:29 Larry Finger wrote:
> On 2.6.32-rc6 from wireless-testing, the following warning is emitted:
> 
> ------------[ cut here ]------------ 
> WARNING: at lib/dma-debug.c:860 check_for_stack+0xaa/0xe0() 
> Hardware name: HP Pavilion dv2700 Notebook PC 
> ehci_hcd 0000:00:02.1: DMA-API: device driver maps memory fromstack
> 	 [addr=ffff8800b6e2bca8] 
> Modules linked in: <Removed> 
> Pid: 16378, comm: modprobe Not tainted 2.6.32-rc6-wl #244 
> Call Trace: 
>  [<ffffffff81049698>] warn_slowpath_common+0x78/0xb0 
>  [<ffffffff8104972c>] warn_slowpath_fmt+0x3c/0x40 
>  [<ffffffff811ae52a>] check_for_stack+0xaa/0xe0 
>  [<ffffffff811afc8d>] debug_dma_map_page+0xfd/0x170 
>  [<ffffffffa006297a>] usb_hcd_submit_urb+0x3da/0x9c0 [usbcore] 
>  [<ffffffff81076e6f>] ? lockdep_init_map+0x5f/0x5d0 
>  [<ffffffffa0063365>] usb_submit_urb+0xe5/0x260 [usbcore] 
>  [<ffffffffa0064b7e>] usb_start_wait_urb+0x5e/0xf0 [usbcore] 
>  [<ffffffffa0063943>] ? usb_init_urb+0x23/0x40 [usbcore] 
>  [<ffffffffa0064cd4>] usb_bulk_msg+0xc4/0x150 [usbcore] 
>  [<ffffffffa0441a91>] T.719+0x31/0x40 [p54usb] 
>  [<ffffffffa0441acf>] p54u_upload_firmware_3887+0x2f/0x490 [p54usb] 
>  [<ffffffffa049c667>] ? p54_parse_firmware+0x427/0x450 [p54common] 
>  <Rest of traceback removed>
> ---[ end trace f77df0316ddad3de ]--- 
> 
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Stable <stable@vger.org>
> ---
> 
> John,
> 
> This is 2.6.32 material. Sorry to find it so late in the rc cycle. I hop
> DaveM doesn't give you too much trouble.
> 
> V2 - Fix line wraps in trace back.
> 
> Larry
> ---
> 
> Index: wireless-testing/drivers/net/wireless/p54/p54usb.c
> ===================================================================
> --- wireless-testing.orig/drivers/net/wireless/p54/p54usb.c
> +++ wireless-testing/drivers/net/wireless/p54/p54usb.c
> @@ -426,12 +426,16 @@ static const char p54u_romboot_3887[] =
>  static int p54u_firmware_reset_3887(struct ieee80211_hw *dev)
>  {
>  	struct p54u_priv *priv = dev->priv;
> -	u8 buf[4];
> +	u8 *buf;
>  	int ret;
>  
> -	memcpy(&buf, p54u_romboot_3887, sizeof(buf));
> +	buf = kmalloc(4, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> + 	memcpy(buf, p54u_romboot_3887, 4);
>  	ret = p54u_bulk_msg(priv, P54U_PIPE_DATA,
> -			    buf, sizeof(buf));
> +			    buf, 4);
> +	kfree(buf);
>  	if (ret)
>  		dev_err(&priv->udev->dev, "(p54usb) unable to jump to "
>  			"boot ROM (%d)!\n", ret);
> 

Acked-by: Christian Lamparter <chunkeey@googlemail.com>

FYI, p54u_upload_firmware_net2280 will likely produce the same
same WARN, since "__le32 reg;" is held on the stack as well.

Regards,
	Chr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] p54usb: Remove DMA buffer from stack
  2009-11-12  9:51 ` Christian Lamparter
@ 2009-11-12 16:27   ` Larry Finger
  0 siblings, 0 replies; 3+ messages in thread
From: Larry Finger @ 2009-11-12 16:27 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: John W Linville, linux-wireless

On 11/12/2009 03:51 AM, Christian Lamparter wrote:
> On Thursday 12 November 2009 01:02:29 Larry Finger wrote:
>> On 2.6.32-rc6 from wireless-testing, the following warning is emitted:
>>
>> ------------[ cut here ]------------ 
>> WARNING: at lib/dma-debug.c:860 check_for_stack+0xaa/0xe0() 
>> Hardware name: HP Pavilion dv2700 Notebook PC 
>> ehci_hcd 0000:00:02.1: DMA-API: device driver maps memory fromstack
>> 	 [addr=ffff8800b6e2bca8] 
-- snip --

> 
> Acked-by: Christian Lamparter <chunkeey@googlemail.com>
> 
> FYI, p54u_upload_firmware_net2280 will likely produce the same
> same WARN, since "__le32 reg;" is held on the stack as well.

I was pretty certain that the WARN is only for DMA buffers on the stack. After
reviewing the code lib/dma-debug.c, nothing changed my mind. In
p54u_upload_firmware_net2280, the buffer is kmalloc'ed already. It should be OK.

Larry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-12 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-12  0:02 [PATCH V2] p54usb: Remove DMA buffer from stack Larry Finger
2009-11-12  9:51 ` Christian Lamparter
2009-11-12 16:27   ` Larry Finger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).