Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1585761
| From | Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] USB: gadgetfs: Fix a potential memory leak in 'dev_config()' |
| Date | 2017-02-21 22:50 +0100 |
| Message-ID | <tdqtP-8mV-7@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
'kbuf' is allocated just a few lines above using 'memdup_user()'.
If the 'if (dev->buf)' test fails, this memory is never released.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/usb/gadget/legacy/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 79a2d8fba6b6..a2c916869293 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1781,8 +1781,10 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
spin_lock_irq (&dev->lock);
value = -EINVAL;
- if (dev->buf)
+ if (dev->buf) {
+ kfree(kbuf);
goto fail;
+ }
dev->buf = kbuf;
/* full or low speed config */
--
2.9.3
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] USB: gadgetfs: Fix a potential memory leak in 'dev_config()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-02-21 22:50 +0100
csiph-web