dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/via: Add new condition to via_dma_cleanup()
@ 2022-07-25 10:45 Alisa Khabibrakhmanova
  2022-07-26 17:23 ` Sam Ravnborg
  0 siblings, 1 reply; 4+ messages in thread
From: Alisa Khabibrakhmanova @ 2022-07-25 10:45 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: ldv-project, Alisa Khabibrakhmanova, linux-kernel, dri-devel

Pointer dev_priv->mmio, which was checked for NULL at via_do_init_map(),
is passed to via_do_cleanup_map() and is dereferenced there without check.

The patch adds the condition in via_dma_cleanup() which prevents potential NULL
pointer dereference.

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

Fixes: 22f579c621e2 ("drm: Add via unichrome support")
Signed-off-by: Alisa Khabibrakhmanova <khabibrakhmanova@ispras.ru>
---
 drivers/gpu/drm/via/via_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 177b0499abf1..56bcbbf4ed54 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -164,7 +164,7 @@ int via_dma_cleanup(struct drm_device *dev)
 		drm_via_private_t *dev_priv =
 		    (drm_via_private_t *) dev->dev_private;
 
-		if (dev_priv->ring.virtual_start) {
+		if (dev_priv->ring.virtual_start && dev_priv->mmio) {
 			via_cmdbuf_reset(dev_priv);
 
 			drm_legacy_ioremapfree(&dev_priv->ring.map, dev);
-- 
2.34.1


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

* Re: [PATCH] drm/via: Add new condition to via_dma_cleanup()
  2022-07-25 10:45 [PATCH] drm/via: Add new condition to via_dma_cleanup() Alisa Khabibrakhmanova
@ 2022-07-26 17:23 ` Sam Ravnborg
  2022-07-29  9:06   ` Alisa Khabibrakhmanova
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2022-07-26 17:23 UTC (permalink / raw)
  To: Alisa Khabibrakhmanova; +Cc: David Airlie, ldv-project, dri-devel, linux-kernel

Hi Alisa,

On Mon, Jul 25, 2022 at 01:45:55PM +0300, Alisa Khabibrakhmanova wrote:
> Pointer dev_priv->mmio, which was checked for NULL at via_do_init_map(),
> is passed to via_do_cleanup_map() and is dereferenced there without check.
> 
> The patch adds the condition in via_dma_cleanup() which prevents potential NULL
> pointer dereference.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 22f579c621e2 ("drm: Add via unichrome support")
> Signed-off-by: Alisa Khabibrakhmanova <khabibrakhmanova@ispras.ru>

Thanks for your patch. Due to other changes in drm-misc where we
maintain the via driver this patch fails to apply.
It would be great if you could redo the patch after -rc2 - on top of
-next. Then we can apply it to drm-misc.

You will see that the individual files for the driver is merged to a
single file, and this change does not hit -next until later.

	Sam

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

* [PATCH] drm/via: Add new condition to via_dma_cleanup()
  2022-07-26 17:23 ` Sam Ravnborg
@ 2022-07-29  9:06   ` Alisa Khabibrakhmanova
  2022-09-06 19:25     ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Alisa Khabibrakhmanova @ 2022-07-29  9:06 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter, Thomas Zimmermann, Sam Ravnborg
  Cc: ldv-project, Alisa Khabibrakhmanova, linux-kernel, dri-devel

Pointer dev_priv->mmio, which was checked for NULL at via_do_init_map(),
is passed to via_do_cleanup_map() and is dereferenced there without check.

The patch adds the condition in via_dma_cleanup() which prevents potential NULL
pointer dereference.

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

Fixes: 22f579c621e2 ("drm: Add via unichrome support")
Signed-off-by: Alisa Khabibrakhmanova <khabibrakhmanova@ispras.ru>
---
 drivers/gpu/drm/via/via_dri1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/via/via_dri1.c b/drivers/gpu/drm/via/via_dri1.c
index d695d9291ece..691e3ceb0062 100644
--- a/drivers/gpu/drm/via/via_dri1.c
+++ b/drivers/gpu/drm/via/via_dri1.c
@@ -2961,7 +2961,7 @@ int via_dma_cleanup(struct drm_device *dev)
 		drm_via_private_t *dev_priv =
 		    (drm_via_private_t *) dev->dev_private;
 
-		if (dev_priv->ring.virtual_start) {
+		if (dev_priv->ring.virtual_start && dev_priv->mmio) {
 			via_cmdbuf_reset(dev_priv);
 
 			drm_legacy_ioremapfree(&dev_priv->ring.map, dev);
-- 
2.34.1


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

* Re: [PATCH] drm/via: Add new condition to via_dma_cleanup()
  2022-07-29  9:06   ` Alisa Khabibrakhmanova
@ 2022-09-06 19:25     ` Daniel Vetter
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2022-09-06 19:25 UTC (permalink / raw)
  To: Alisa Khabibrakhmanova
  Cc: ldv-project, David Airlie, linux-kernel, dri-devel,
	Thomas Zimmermann, Sam Ravnborg

On Fri, Jul 29, 2022 at 12:06:43PM +0300, Alisa Khabibrakhmanova wrote:
> Pointer dev_priv->mmio, which was checked for NULL at via_do_init_map(),
> is passed to via_do_cleanup_map() and is dereferenced there without check.
> 
> The patch adds the condition in via_dma_cleanup() which prevents potential NULL
> pointer dereference.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 22f579c621e2 ("drm: Add via unichrome support")
> Signed-off-by: Alisa Khabibrakhmanova <khabibrakhmanova@ispras.ru>

This seems to have fallen through cracks, I applied it to drm-misc-next
now.

Thanks for your patch.
-Daniel

> ---
>  drivers/gpu/drm/via/via_dri1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/via/via_dri1.c b/drivers/gpu/drm/via/via_dri1.c
> index d695d9291ece..691e3ceb0062 100644
> --- a/drivers/gpu/drm/via/via_dri1.c
> +++ b/drivers/gpu/drm/via/via_dri1.c
> @@ -2961,7 +2961,7 @@ int via_dma_cleanup(struct drm_device *dev)
>  		drm_via_private_t *dev_priv =
>  		    (drm_via_private_t *) dev->dev_private;
>  
> -		if (dev_priv->ring.virtual_start) {
> +		if (dev_priv->ring.virtual_start && dev_priv->mmio) {
>  			via_cmdbuf_reset(dev_priv);
>  
>  			drm_legacy_ioremapfree(&dev_priv->ring.map, dev);
> -- 
> 2.34.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

end of thread, other threads:[~2022-09-06 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25 10:45 [PATCH] drm/via: Add new condition to via_dma_cleanup() Alisa Khabibrakhmanova
2022-07-26 17:23 ` Sam Ravnborg
2022-07-29  9:06   ` Alisa Khabibrakhmanova
2022-09-06 19:25     ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).