mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liu Ying <victor.liu@oss.nxp.com>
To: Chenyuan Yang <chenyuan0y@gmail.com>, Maxime Ripard <mripard@kernel.org>
Cc: airlied@gmail.com, andrzej.hajda@intel.com,
	biju.das.jz@bp.renesas.com, dri-devel@lists.freedesktop.org,
	jernej.skrabec@gmail.com, jonas@kwiboo.se,
	laurent.pinchart@ideasonboard.com, linux-kernel@vger.kernel.org,
	lumag@kernel.org, maarten.lankhorst@linux.intel.com,
	neil.armstrong@linaro.org, rfoss@kernel.org, simona@ffwll.ch,
	tzimmermann@suse.de, victor.liu@nxp.com
Subject: Re: [PATCH] drm/bridge: Add null pointer check for ITE IT6263
Date: Thu, 24 Jul 2025 10:01:39 +0800	[thread overview]
Message-ID: <97be55dc-c274-4836-bdac-25c3d2c23d24@oss.nxp.com> (raw)
In-Reply-To: <CALGdzuoprX2Q=vwOENrmAbPbJb+XeBjQqG90YEOApSbW9uKeZg@mail.gmail.com>

Hi Chenyuan,

On 07/23/2025, Chenyuan Yang wrote:
> On Tue, Jul 22, 2025 at 23:57 Maxime Ripard <mripard@kernel.org> wrote:
> 
>> On Tue, Jul 22, 2025 at 03:41:14PM -0500, Chenyuan Yang wrote:
>>> drm_atomic_get_new_connector_for_encoder and
>>> drm_atomic_get_new_connector_state could return Null.
>>
>> They can, but not in that scenario. atomic_enable will never be called
>> if either would return NULL.
>>
>> In which situation did you trigger this bug?
> 
> 
> This is found by our static analysis tool based on the fact that
> drm_atomic_get_new_connector_state() could return NULL. We also noticed
> that under the same dir, ITE IT6505 transmitter has such checks. Thus, we
> assume it would be good to have similar checks here.

You need to properly triage the tool's report, which means if there is
no real case that could produce those NULL pointers, then the report
should be false-positive, otherwise show us any real case that could in
commit message.  Assuming the checks are needed is not good enough.
Please do your home work before sending the patch.

> 
> 
>>> Thus, add the null pointer check for them with a similar format with
>>> it6505_bridge_atomic_enable in ITE IT6505.
>>>
>>> Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
>>> Fixes: 049723628716 ("drm/bridge: Add ITE IT6263 LVDS to HDMI converter")
>>> ---
>>>  drivers/gpu/drm/bridge/ite-it6263.c | 15 ++++++++++++++-
>>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/ite-it6263.c
>> b/drivers/gpu/drm/bridge/ite-it6263.c
>>> index a3a63a977b0a..3a20b2088bf9 100644
>>> --- a/drivers/gpu/drm/bridge/ite-it6263.c
>>> +++ b/drivers/gpu/drm/bridge/ite-it6263.c
>>> @@ -590,15 +590,28 @@ static void it6263_bridge_atomic_enable(struct
>> drm_bridge *bridge,
>>>       struct drm_connector *connector;
>>>       bool is_stable = false;
>>>       struct drm_crtc *crtc;
>>> +     struct drm_connector_state *conn_state;
>>>       unsigned int val;
>>>       bool pclk_high;
>>>       int i, ret;
>>>
>>>       connector = drm_atomic_get_new_connector_for_encoder(state,
>>>
>> bridge->encoder);
>>> -     crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
>>> +     if (WARN_ON(!connector))
>>> +             return;
>>> +
>>> +     conn_state = drm_atomic_get_new_connector_state(state, connector);
>>> +     if (WARN_ON(!conn_state))
>>> +             return;
>>> +
>>> +     crtc = conn_state->crtc;
>>>       crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
>>> +     if (WARN_ON(!crtc_state))
>>> +             return;
>>> +
>>>       mode = &crtc_state->adjusted_mode;
>>> +     if (WARN_ON(!mode))
>>> +             return;
>>
>> And that condition can never be true.
>>
>> Maxime
>>
> 


-- 
Regards,
Liu Ying

      parent reply	other threads:[~2025-07-24  2:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 20:41 Chenyuan Yang
2025-07-23  5:19 ` Biju Das
2025-07-23  6:57 ` Maxime Ripard
2025-07-23 16:09   ` Chenyuan Yang
     [not found]   ` <CALGdzuoprX2Q=vwOENrmAbPbJb+XeBjQqG90YEOApSbW9uKeZg@mail.gmail.com>
2025-07-24  2:01     ` Liu Ying [this message]

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=97be55dc-c274-4836-bdac-25c3d2c23d24@oss.nxp.com \
    --to=victor.liu@oss.nxp.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=chenyuan0y@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=victor.liu@nxp.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

all inboxes | Powered by JetHome®