mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nouveau_connector: add nv_encoder pointer check for NULL
@ 2023-05-12 10:33 Natalia Petrova
  2023-06-13 20:52 ` Lyude Paul
  0 siblings, 1 reply; 2+ messages in thread
From: Natalia Petrova @ 2023-05-12 10:33 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: Natalia Petrova, Karol Herbst, Lyude Paul, David Airlie,
	Daniel Vetter, dri-devel, nouveau, linux-kernel, lvc-project

Pointer nv_encoder could be dereferenced at nouveau_connector.c
in case it's equal to NULL by jumping to goto label.
This patch adds a NULL-check to avoid it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 3195c5f9784a ("drm/nouveau: set encoder for lvds")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 43a9d1e1cf71..90ba6d0a9c80 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -729,7 +729,8 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
 #endif
 
 	nouveau_connector_set_edid(nv_connector, edid);
-	nouveau_connector_set_encoder(connector, nv_encoder);
+	if (nv_encoder)
+		nouveau_connector_set_encoder(connector, nv_encoder);
 	return status;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] nouveau_connector: add nv_encoder pointer check for NULL
  2023-05-12 10:33 [PATCH] nouveau_connector: add nv_encoder pointer check for NULL Natalia Petrova
@ 2023-06-13 20:52 ` Lyude Paul
  0 siblings, 0 replies; 2+ messages in thread
From: Lyude Paul @ 2023-06-13 20:52 UTC (permalink / raw)
  To: Natalia Petrova, Ben Skeggs
  Cc: Karol Herbst, David Airlie, Daniel Vetter, dri-devel, nouveau,
	linux-kernel, lvc-project

Nice catch!

Reviewed-by: Lyude Paul <lyude@redhat.com>

Will push upstream

On Fri, 2023-05-12 at 13:33 +0300, Natalia Petrova wrote:
> Pointer nv_encoder could be dereferenced at nouveau_connector.c
> in case it's equal to NULL by jumping to goto label.
> This patch adds a NULL-check to avoid it.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 3195c5f9784a ("drm/nouveau: set encoder for lvds")
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
> ---
>  drivers/gpu/drm/nouveau/nouveau_connector.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
> index 43a9d1e1cf71..90ba6d0a9c80 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> @@ -729,7 +729,8 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
>  #endif
>  
>  	nouveau_connector_set_edid(nv_connector, edid);
> -	nouveau_connector_set_encoder(connector, nv_encoder);
> +	if (nv_encoder)
> +		nouveau_connector_set_encoder(connector, nv_encoder);
>  	return status;
>  }
>  

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-13 20:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 10:33 [PATCH] nouveau_connector: add nv_encoder pointer check for NULL Natalia Petrova
2023-06-13 20:52 ` Lyude Paul

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®