[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20221208021549.26704-1-jiasheng@iscas.ac.cn>
Date: Thu, 8 Dec 2022 10:15:49 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: robin.murphy@....com, liviu.dudau@....com, brian.starkey@....com,
airlied@...il.com, daniel@...ll.ch
Cc: linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: Re: [PATCH] drm: mali-dp: Add check for kzalloc
On Wed, Dec 07, 2022 at 09:59:04PM +0800, Robin Murphy wrote:
>> As kzalloc may fail and return NULL pointer, it should be better to check
>> the return value in order to avoid the NULL pointer dereference in
>> __drm_atomic_helper_connector_reset.
>
> This commit message is nonsense; if
> __drm_atomic_helper_connector_reset() would dereference the NULL implied
> by &mw_state->base, it would equally still dereference the explicit NULL
> pointer passed after this patch.
>
> The current code works out OK because "base" is the first member of
> struct malidp_mw_connector_state, thus if mw_state is NULL then
> &mw_state->base == NULL + 0 == NULL. Now you *could* argue that this
> isn't robust if the layout of struct malidp_mw_connector_state ever
> changes, and that could be a valid justification for making this change,
> but the reason given certainly isn't.
>
> Arithmetic on a (potentially) NULL pointer may well be a sign that it's
> worth a closer look to check whether it really is what the code intended
> to do, but don't automatically assume it has to be a bug. Otherwise,
> good luck with "fixing" every user of container_of() throughout the
> entire kernel.
I have sent a new patch with the modified commit mesage.
Thanks,
Jiang
Powered by blists - more mailing lists