Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH] watchdog: pcwd_usb: Use allocated buffer for usb_control_msg
@ 2013-10-14 16:29 Guenter Roeck
  2013-10-14 16:34 ` Greg Kroah-Hartman
  2013-10-29  7:51 ` Wim Van Sebroeck
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2013-10-14 16:29 UTC (permalink / raw)
  To: linux-watchdog; +Cc: Wim Van Sebroeck, Greg Kroah-Hartman, Guenter Roeck

usb_control_msg() must use a dma-capable buffer.

This fixes the following error reported by smatch:

drivers/watchdog/pcwd_usb.c:257 usb_pcwd_send_command() error: doing dma on the
stack (buf)

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/pcwd_usb.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index 7b14d18..115a0eb 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -235,13 +235,17 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 		unsigned char cmd, unsigned char *msb, unsigned char *lsb)
 {
 	int got_response, count;
-	unsigned char buf[6];
+	unsigned char *buf;
 
 	/* We will not send any commands if the USB PCWD device does
 	 * not exist */
 	if ((!usb_pcwd) || (!usb_pcwd->exists))
 		return -1;
 
+	buf = kmalloc(6, GFP_KERNEL);
+	if (buf == NULL)
+		return 0;
+
 	/* The USB PC Watchdog uses a 6 byte report format.
 	 * The board currently uses only 3 of the six bytes of the report. */
 	buf[0] = cmd;			/* Byte 0 = CMD */
@@ -277,6 +281,8 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 		*lsb = usb_pcwd->cmd_data_lsb;
 	}
 
+	kfree(buf);
+
 	return got_response;
 }
 
-- 
1.7.9.7

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

end of thread, other threads:[~2013-10-29  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-14 16:29 [PATCH] watchdog: pcwd_usb: Use allocated buffer for usb_control_msg Guenter Roeck
2013-10-14 16:34 ` Greg Kroah-Hartman
2013-10-29  7:51 ` Wim Van Sebroeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox