[PATCH] drm/meson: add check to prevent dereference of NULL
Anastasia Belova
abelova at astralinux.ru
Mon Aug 12 02:30:57 PDT 2024
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 at astralinux.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
More information about the linux-amlogic
mailing list