lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190917024147.26290-1-navid.emamdoost@gmail.com>
Date:   Mon, 16 Sep 2019 21:41:43 -0500
From:   Navid Emamdoost <navid.emamdoost@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     emamd001@....edu, smccaman@....edu, kjlu@....edu,
        Navid Emamdoost <navid.emamdoost@...il.com>,
        Ian Abbott <abbotti@....co.uk>,
        H Hartley Sweeten <hsweeten@...ionengravers.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH] staging: comedi: drivers: prevent memory leak

In das1800_attach, the buffer allocated via kmalloc_array needs to be
released if an error happens.

Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>
---
 drivers/staging/comedi/drivers/das1800.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index f16aa7e9f4f3..5f2d5f7a6229 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -1237,12 +1237,16 @@ static int das1800_attach(struct comedi_device *dev,
 
 	dev->pacer = comedi_8254_init(dev->iobase + DAS1800_COUNTER,
 				      I8254_OSC_BASE_5MHZ, I8254_IO8, 0);
-	if (!dev->pacer)
+	if (!dev->pacer) {
+		kfree(devpriv->fifo_buf);
 		return -ENOMEM;
+	}
 
 	ret = comedi_alloc_subdevices(dev, 4);
-	if (ret)
+	if (ret) {
+		kfree(devpriv->fifo_buf);
 		return ret;
+	}
 
 	/*
 	 * Analog Input subdevice
@@ -1290,8 +1294,10 @@ static int das1800_attach(struct comedi_device *dev,
 		s->insn_write	= das1800_ao_insn_write;
 
 		ret = comedi_alloc_subdev_readback(s);
-		if (ret)
+		if (ret) {
+			kfree(devpriv->fifo_buf);
 			return ret;
+		}
 
 		/* initialize all channels to 0V */
 		for (i = 0; i < s->n_chan; i++) {
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ