linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ma Ke <make_ruc2021@163.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Ma Ke <make_ruc2021@163.com>
Subject: [PATCH] drm/edid: fix a possible null pointer dereference
Date: Wed, 11 Oct 2023 09:33:16 +0800	[thread overview]
Message-ID: <20231011013316.4091845-1-make_ruc2021@163.com> (raw)

In drm_mode_std(), the return value of drm_gtf_mode(),
drm_gtf_mode() and drm_cvt_mode() is assigned to mode,
which will lead to a NULL pointer dereference on failure
of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode().
Add a check to avoid null point dereference.

Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 drivers/gpu/drm/drm_edid.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 340da8257b51..e2c154c2b896 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3381,6 +3381,8 @@ static struct drm_display_mode *drm_mode_std(struct drm_connector *connector,
 				    false);
 		break;
 	}
+	if (!mode)
+		return NULL;
 	return mode;
 }
 
-- 
2.37.2


             reply	other threads:[~2023-10-11  1:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  1:33 Ma Ke [this message]
2023-10-11  7:10 ` [PATCH] drm/edid: fix a possible null pointer dereference Jani Nikula

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=20231011013316.4091845-1-make_ruc2021@163.com \
    --to=make_ruc2021@163.com \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).