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>] [day] [month] [year] [list]
Date:	Sun, 12 Jun 2016 15:56:34 +0100
From:	Sudip Mukherjee <sudipm.mukherjee@...il.com>
To:	Ben Skeggs <bskeggs@...hat.com>, David Airlie <airlied@...ux.ie>
Cc:	linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
	nouveau@...ts.freedesktop.org,
	Sudip Mukherjee <sudipm.mukherjee@...il.com>
Subject: [PATCH] drm/nouveau/iccsense: fix memory leak

In the for loop we are allocating the memory for rail everytime but
in some cases we use "continue" and in those cases the memory already
allocated for rail is leaked and we again allocate new memory for it.
Lets free the memory before continuing with the loop.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@...ethink.co.uk>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index 323c79a..756ff07 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -290,21 +290,28 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
 
 		switch (sensor->type) {
 		case NVBIOS_EXTDEV_INA209:
-			if (r->rail != 0)
+			if (r->rail != 0) {
+				kfree(rail);
 				continue;
+			}
 			rail->read = nvkm_iccsense_ina209_read;
 			break;
 		case NVBIOS_EXTDEV_INA219:
-			if (r->rail != 0)
+			if (r->rail != 0) {
+				kfree(rail);
 				continue;
+			}
 			rail->read = nvkm_iccsense_ina219_read;
 			break;
 		case NVBIOS_EXTDEV_INA3221:
-			if (r->rail >= 3)
+			if (r->rail >= 3) {
+				kfree(rail);
 				continue;
+			}
 			rail->read = nvkm_iccsense_ina3221_read;
 			break;
 		default:
+			kfree(rail);
 			continue;
 		}
 
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ