mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: alexander.levin@verizon.com
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	alexander.levin@verizon.com
Subject: [PATCH AUTOSEL for 3.18 03/16] USB: gadgetfs: Fix a potential memory leak in 'dev_config()'
Date: Wed, 29 Nov 2017 17:22:19 +0000	[thread overview]
Message-ID: <20171129172213.29007-3-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171129172213.29007-1-alexander.levin@verizon.com>

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

[ Upstream commit b6e7aeeaf235901c42ec35de4633c7c69501d303 ]

'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>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 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 368d07937848..e2d57e3d67c7 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1921,8 +1921,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.11.0

  reply	other threads:[~2017-11-29 17:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 17:22 [PATCH AUTOSEL for 3.18 01/16] selftest/powerpc: Fix false failures for skipped tests alexander.levin
2017-11-29 17:22 ` alexander.levin [this message]
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 04/16] libata: drop WARN from protocol error in ata_sff_qc_issue() alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 02/16] usb: gadget: configs: plug memory leak alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 08/16] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 05/16] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 07/16] irqchip/crossbar: Fix incorrect type of register size alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 06/16] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 09/16] arm: KVM: Survive unknown traps from guests alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 10/16] spi_ks8995: fix "BUG: key accdaa28 not in .data!" alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 11/16] bnx2x: fix possible overrun of VFPF multicast addresses array alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 12/16] ipv6: reorder icmpv6_init() and ip6_mr_init() alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 15/16] axonram: Fix gendisk handling alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 16/16] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro alexander.levin
2017-11-30  1:34   ` Jérémy Lefaure
2017-11-30 21:33     ` alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 13/16] crypto: s5p-sss - Fix completing crypto request in IRQ handler alexander.levin
2017-11-29 17:22 ` [PATCH AUTOSEL for 3.18 14/16] i2c: riic: fix restart condition alexander.levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171129172213.29007-3-alexander.levin@verizon.com \
    --to=alexander.levin@verizon.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=felipe.balbi@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®