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: <20191027173234.6449-1-navid.emamdoost@gmail.com>
Date:   Sun, 27 Oct 2019 12:32:33 -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>,
        Eric Anholt <eric@...olt.net>, David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/tinydrm: Fix memroy leak in hx8357d_probe

In the implementation of hx8357d_probe() the allocated memory for dbidev
is leaked when an error happens. Release dbidev if any of the  following
calls fail: devm_gpiod_get(), devm_of_find_backlight(),
mipi_dbi_spi_init(), mipi_dbi_init(), drm_dev_register().

Fixes: f300c86e33a6 ("drm: Add an hx8367d tinydrm driver.")
Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>
---
 drivers/gpu/drm/tiny/hx8357d.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index 9af8ff84974f..da5ec944f47e 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -232,44 +232,49 @@ static int hx8357d_probe(struct spi_device *spi)
 
 	drm = &dbidev->drm;
 	ret = devm_drm_dev_init(dev, drm, &hx8357d_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
+	if (ret)
+		goto free_dbidev;
 
 	drm_mode_config_init(drm);
 
 	dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
 	if (IS_ERR(dc)) {
 		DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
-		return PTR_ERR(dc);
+		ret = PTR_ERR(dc);
+		goto free_dbidev;
 	}
 
 	dbidev->backlight = devm_of_find_backlight(dev);
-	if (IS_ERR(dbidev->backlight))
-		return PTR_ERR(dbidev->backlight);
+	if (IS_ERR(dbidev->backlight)) {
+		ret = PTR_ERR(dbidev->backlight);
+		goto free_dbidev;
+	}
 
 	device_property_read_u32(dev, "rotation", &rotation);
 
 	ret = mipi_dbi_spi_init(spi, &dbidev->dbi, dc);
 	if (ret)
-		return ret;
+		goto free_dbidev;
 
 	ret = mipi_dbi_dev_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation);
 	if (ret)
-		return ret;
+		goto free_dbidev;
 
 	drm_mode_config_reset(drm);
 
 	ret = drm_dev_register(drm, 0);
 	if (ret)
-		return ret;
+		goto free_dbidev;
 
 	spi_set_drvdata(spi, drm);
 
 	drm_fbdev_generic_setup(drm, 0);
 
 	return 0;
+
+free_dbidev:
+	kfree(dbidev);
+	return ret;
 }
 
 static int hx8357d_remove(struct spi_device *spi)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ