linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Zhang Shurong <zhang_shurong@foxmail.com>
Cc: victor.liu@nxp.com, andrzej.hajda@intel.com,
	neil.armstrong@linaro.org, rfoss@kernel.org, jonas@kwiboo.se,
	jernej.skrabec@gmail.com, airlied@gmail.com, daniel@ffwll.ch,
	shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: imx: fix potential NULL pointer dereference in imx8qxp_ldb_parse_dt_companion()
Date: Mon, 28 Aug 2023 20:28:22 +0300	[thread overview]
Message-ID: <20230828172822.GE14596@pendragon.ideasonboard.com> (raw)
In-Reply-To: <tencent_026E4B04ACDCE341411EF54862F8C6AB1605@qq.com>

Hi Zhang,

Thank you for the patch.

On Tue, Aug 29, 2023 at 12:55:01AM +0800, Zhang Shurong wrote:
> of_match_device() may fail and returns a NULL pointer.

How can it return a NULL pointer here ?

> Fix this by checking the return value of of_match_device().
> 
> Fixes: 3818715f62b4 ("drm/bridge: imx: Add LDB support for i.MX8qxp")
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> ---
>  drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
> index 7984da9c0a35..d272f35c8eac 100644
> --- a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
> +++ b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
> @@ -488,6 +488,8 @@ static int imx8qxp_ldb_parse_dt_companion(struct imx8qxp_ldb *imx8qxp_ldb)
>  	 * string.
>  	 */
>  	match = of_match_device(dev->driver->of_match_table, dev);
> +	if (!match)
> +		return -ENODEV;
>  	if (!of_device_is_compatible(companion, match->compatible)) {
>  		DRM_DEV_ERROR(dev, "companion LDB is incompatible\n");
>  		ret = -ENXIO;

-- 
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-28 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 16:55 [PATCH] drm/bridge: imx: fix potential NULL pointer dereference in imx8qxp_ldb_parse_dt_companion() Zhang Shurong
2023-08-28 17:28 ` Laurent Pinchart [this message]
2023-08-28 18:01   ` Zhang Shurong
2023-08-28 18:37     ` Laurent Pinchart
2023-08-29  2:28       ` Ying Liu

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=20230828172822.GE14596@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=victor.liu@nxp.com \
    --cc=zhang_shurong@foxmail.com \
    /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).