The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ma Ke <make24@iscas.ac.cn>,
	patrik.r.jakobsson@gmail.com, 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 <make24@iscas.ac.cn>
Subject: Re: [PATCH] drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes
Date: Wed, 26 Jun 2024 12:44:48 +0300	[thread overview]
Message-ID: <8734p0domn.fsf@intel.com> (raw)
In-Reply-To: <20240626011656.2763368-1-make24@iscas.ac.cn>

On Wed, 26 Jun 2024, Ma Ke <make24@iscas.ac.cn> wrote:
> In psb_intel_lvds_get_modes(), the return value of drm_mode_duplicate() is
> assigned to mode, which will lead to a possible NULL pointer dereference
> on failure of drm_mode_duplicate(). Add a check to avoid npd.
>
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  drivers/gpu/drm/gma500/psb_intel_lvds.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c b/drivers/gpu/drm/gma500/psb_intel_lvds.c
> index 8486de230ec9..aa5bf2a8a319 100644
> --- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
> +++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
> @@ -504,6 +504,8 @@ static int psb_intel_lvds_get_modes(struct drm_connector *connector)
>  	if (mode_dev->panel_fixed_mode != NULL) {
>  		struct drm_display_mode *mode =
>  		    drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
> +		if (!mode)
> +			return -ENOMEM;

Do not return negative values from .get_modes().

BR,
Jani.

>  		drm_mode_probed_add(connector, mode);
>  		return 1;
>  	}

-- 
Jani Nikula, Intel

  reply	other threads:[~2024-06-26  9:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26  1:16 [PATCH] drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes Ma Ke
2024-06-26  9:44 ` Jani Nikula [this message]
2024-06-26 10:18 ` Markus Elfring

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=8734p0domn.fsf@intel.com \
    --to=jani.nikula@linux.intel.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=make24@iscas.ac.cn \
    --cc=mripard@kernel.org \
    --cc=patrik.r.jakobsson@gmail.com \
    --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