[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bb45ed80-7871-47ba-a1fd-ee71dc21a409@astralinux.ru>
Date: Mon, 12 Aug 2024 12:30:57 +0300
From: Anastasia Belova <abelova@...ralinux.ru>
To: Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Cc: Neil Armstrong <neil.armstrong@...aro.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Kevin Hilman <khilman@...libre.com>, Jerome Brunet <jbrunet@...libre.com>,
dri-devel@...ts.freedesktop.org, linux-amlogic@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
lvc-project@...uxtesting.org
Subject: Re: [PATCH] drm/meson: add check to prevent dereference of NULL
Hello Martin,
10/08/24 12:09, Martin Blumenstingl пишет:
> Hello Anastasia,
>
> Thank you for working on this!
>
> On Fri, Aug 9, 2024 at 2:48 PM Anastasia Belova <abelova@...ralinux.ru> wrote:
> [...]
>> @@ -373,9 +373,11 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
>> free_drm:
>> drm_dev_put(drm);
>>
>> - meson_encoder_dsi_remove(priv);
>> - meson_encoder_hdmi_remove(priv);
>> - meson_encoder_cvbs_remove(priv);
>> + if (priv) {
>> + meson_encoder_dsi_remove(priv);
>> + meson_encoder_hdmi_remove(priv);
>> + meson_encoder_cvbs_remove(priv);
>> + }
> This is the straight-forward approach.
>
> There's been conversions from non-devm_ functions to their devm_*
> counterparts in the past in various subsystems.
> I just found that there's a devm_drm_dev_alloc() which seems to be
> calling drm_dev_put() automatically - but I have never used it myself
> before.
> As an alternative to your suggested approach: could you please look
> into whether devm_drm_dev_alloc() is a suitable replacement (if not:
> just explain why - then this patch is good to be merged)?
If I understood correctly, devm_drm_dev_alloc allows to delete drm_dev_put
from error path in meson_drv_bind_master and in meson_drv_unbind.
Then the proposed check may be ommited and function may just return
instead of jumping to free_drm.
And would it be better to rename free_drm to remove_encoders?
Thank you,
Anastasia Belova
Powered by blists - more mailing lists