The return value of kzalloc() needs to be checked.
To avoid use of null pointer '&mw_state->base' in case of the
failure of alloc.
Fixes: 8cbc5caf36ef ("drm: mali-dp: Add writeback connector")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/gpu/drm/arm/malidp_mw.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c
index f5847a79dd7e..612d386ee7d2 100644
--- a/drivers/gpu/drm/arm/malidp_mw.c
+++ b/drivers/gpu/drm/arm/malidp_mw.c
@@ -70,7 +70,11 @@ static void malidp_mw_connector_reset(struct drm_connector *connector)
__drm_atomic_helper_connector_destroy_state(connector->state);
kfree(connector->state);
- __drm_atomic_helper_connector_reset(connector, &mw_state->base);
+
+ if (mw_state)
+ __drm_atomic_helper_connector_reset(connector, &mw_state->base);
+ else
+ __drm_atomic_helper_connector_reset(connector, NULL);
}
static enum drm_connector_status
--
2.25.1
Hi Jiasheng,
Thanks for the patch, that's a careless copy-paste on my part :-(
On Tue, Dec 14, 2021 at 06:00:00PM +0800, Jiasheng Jiang wrote:
> The return value of kzalloc() needs to be checked.
> To avoid use of null pointer '&mw_state->base' in case of the
> failure of alloc.
>
> Fixes: 8cbc5caf36ef ("drm: mali-dp: Add writeback connector")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> ---
Reviewed-by: Brian Starkey <[email protected]>
> drivers/gpu/drm/arm/malidp_mw.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c
> index f5847a79dd7e..612d386ee7d2 100644
> --- a/drivers/gpu/drm/arm/malidp_mw.c
> +++ b/drivers/gpu/drm/arm/malidp_mw.c
> @@ -70,7 +70,11 @@ static void malidp_mw_connector_reset(struct drm_connector *connector)
> __drm_atomic_helper_connector_destroy_state(connector->state);
>
> kfree(connector->state);
> - __drm_atomic_helper_connector_reset(connector, &mw_state->base);
> +
> + if (mw_state)
> + __drm_atomic_helper_connector_reset(connector, &mw_state->base);
> + else
> + __drm_atomic_helper_connector_reset(connector, NULL);
> }
>
> static enum drm_connector_status
> --
> 2.25.1
>