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]
Message-Id: <1263113593-6786-1-git-send-email-jslaby@suse.cz>
Date:	Sun, 10 Jan 2010 09:53:13 +0100
From:	Jiri Slaby <jslaby@...e.cz>
To:	airlied@...ux.ie
Cc:	dri-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
	jirislaby@...il.com
Subject: [PATCH] GPU: drm/i915, fix potential null dereference

Stanse found a potential null dereference in i915_suspend.
There is a check for dev and dev_priv being NULL, but dev is
dereferenced earlier. Move the dereference after the check.

Signed-off-by: Jiri Slaby <jslaby@...e.cz>
---
 drivers/gpu/drm/i915/i915_drv.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 2ffffd7..6fc4473 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -173,12 +173,17 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
 
 static int i915_suspend(struct drm_device *dev, pm_message_t state)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_private *dev_priv;
 
-	if (!dev || !dev_priv) {
-		DRM_ERROR("dev: %p, dev_priv: %p\n", dev, dev_priv);
-		DRM_ERROR("DRM not initialized, aborting suspend.\n");
-		return -ENODEV;
+	if (!dev) {
+		DRM_ERROR("dev: %p\n", dev);
+		goto abort;
+	}
+
+	dev_priv = dev->dev_private;
+	if (!dev_priv) {
+		DRM_ERROR("dev_priv: %p\n", dev_priv);
+		goto abort;
 	}
 
 	if (state.event == PM_EVENT_PRETHAW)
@@ -208,6 +213,9 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
 	dev_priv->modeset_on_lid = 0;
 
 	return 0;
+abort:
+	DRM_ERROR("DRM not initialized, aborting suspend.\n");
+	return -ENODEV;
 }
 
 static int i915_resume(struct drm_device *dev)
-- 
1.6.5.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ