diff mbox

dwc3: add a kfree() on error to dwc3_testmode_open()

Message ID 20110826092113.GO5975@shale.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Aug. 26, 2011, 9:21 a.m. UTC
We may as well fix this potential leak so we don't have to listen to
the static checkers complain.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Btw.  This function returns -EBUSY on success.  Was that really what
you want?

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Felipe Balbi Aug. 26, 2011, 9:43 a.m. UTC | #1
Hi,

On Fri, Aug 26, 2011 at 12:21:13PM +0300, Dan Carpenter wrote:
> We may as well fix this potential leak so we don't have to listen to
> the static checkers complain.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

applied, thanks
Sebastian Andrzej Siewior Aug. 26, 2011, 10:32 a.m. UTC | #2
* Dan Carpenter | 2011-08-26 12:21:13 [+0300]:

>Btw.  This function returns -EBUSY on success.  Was that really what
>you want?

At that time yes. The idea was to enable the self-test mode of the core
and let it do transfers forth and back and see if it works. There is
also no off switch. I wasn't aware that this piece of code is going to
merged but now I think we need an off switch.
Thanks for spotting this.

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Felipe Balbi Aug. 26, 2011, 10:48 a.m. UTC | #3
Hi,

On Fri, Aug 26, 2011 at 12:32:40PM +0200, Sebastian Andrzej Siewior wrote:
> * Dan Carpenter | 2011-08-26 12:21:13 [+0300]:
> 
> >Btw.  This function returns -EBUSY on success.  Was that really what
> >you want?
> 
> At that time yes. The idea was to enable the self-test mode of the core
> and let it do transfers forth and back and see if it works. There is
> also no off switch. I wasn't aware that this piece of code is going to
> merged but now I think we need an off switch.

yeah, this is rather useful to test the underlying HW. We had the same
feature on MUSB and it helped check if EP0 handling and FIFO access was
working fine.

> Thanks for spotting this.

indeed.
diff mbox

Patch

diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 432df53..dd861c4 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -445,8 +445,10 @@  static int dwc3_testmode_open(struct inode *inode, struct file *file)
 	if (!buf0)
 		return -ENOMEM;
 	buf1 = kmalloc(BUF_SIZE, GFP_KERNEL);
-	if (!buf1)
+	if (!buf1) {
+		kfree(buf0);
 		return -ENOMEM;
+	}
 
 	memset(buf0, 0xaa, BUF_SIZE);
 	memset(buf1, 0x33, BUF_SIZE);