AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ernst Sjöstrand" <ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: "Ernst Sjöstrand" <ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 2/3] amdgpu/dc: Fix potential null dereference in amdgpu_dm.c
Date: Tue,  7 Nov 2017 00:54:41 +0100	[thread overview]
Message-ID: <20171106235442.20636-3-ernstp@gmail.com> (raw)
In-Reply-To: <20171106235442.20636-1-ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e6bfa9f30900..2301589e4cc3 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2413,6 +2413,8 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
 		return NULL;
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	if (!state)
+		return NULL;
 
 	__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
 
@@ -3443,6 +3445,8 @@ create_i2c(struct ddc_service *ddc_service,
 	struct amdgpu_i2c_adapter *i2c;
 
 	i2c = kzalloc(sizeof(struct amdgpu_i2c_adapter), GFP_KERNEL);
+	if (!i2c)
+		return NULL;
 	i2c->base.owner = THIS_MODULE;
 	i2c->base.class = I2C_CLASS_DDC;
 	i2c->base.dev.parent = &adev->pdev->dev;
@@ -3473,6 +3477,11 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
 	DRM_DEBUG_DRIVER("%s()\n", __func__);
 
 	i2c = create_i2c(link->ddc, link->link_index, &res);
+	if (!i2c) {
+		DRM_ERROR("Failed to create i2c adapter data\n");
+		return -1;
+	}
+
 	aconnector->i2c = i2c;
 	res = i2c_add_adapter(&i2c->base);
 
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-11-06 23:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 23:54 More smatch fixes Ernst Sjöstrand
     [not found] ` <20171106235442.20636-1-ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-06 23:54   ` [PATCH 1/3] amdgpu/dc: fix more indentation warnings Ernst Sjöstrand
2017-11-06 23:54   ` Ernst Sjöstrand [this message]
     [not found]     ` <20171106235442.20636-3-ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-07 14:15       ` [PATCH 2/3] amdgpu/dc: Fix potential null dereference in amdgpu_dm.c Deucher, Alexander
2017-11-06 23:54   ` [PATCH 3/3] amdgpu/dc: Fix missing null checks " Ernst Sjöstrand
     [not found]     ` <20171106235442.20636-4-ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-07 10:33       ` Christian König
2017-11-07 14:18       ` Deucher, Alexander
     [not found]         ` <BN6PR12MB16521997C895FAC6062A77FAF7510-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-11-07 19:52           ` Ernst Sjöstrand
     [not found]             ` <CAD=4a=XB89VfDF2Vjk-7diHjuNFT14f3+-Am79mnUMqa5-bPiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-07 19:57               ` Alex Deucher

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=20171106235442.20636-3-ernstp@gmail.com \
    --to=ernstp-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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