linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] m501fb: don't return zero on failure path in sm501fb_probe()
@ 2014-10-31 22:40 Alexey Khoroshilov
  2014-11-06 14:22 ` Tomi Valkeinen
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2014-10-31 22:40 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen
  Cc: Alexey Khoroshilov, linux-fbdev, linux-kernel, ldv-project

If no framebuffers found, sm501fb_probe() breaks off initialization,
deallocates sm501fb_info, but returns zero. As a result, use after free
can happen in sm501fb_remove().

The patch adds -ENODEV as a return value in this case.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/video/fbdev/sm501fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
index 9e74e8fbe074..8b98b011fc04 100644
--- a/drivers/video/fbdev/sm501fb.c
+++ b/drivers/video/fbdev/sm501fb.c
@@ -1988,6 +1988,7 @@ static int sm501fb_probe(struct platform_device *pdev)
 	if (info->fb[HEAD_PANEL] = NULL &&
 	    info->fb[HEAD_CRT] = NULL) {
 		dev_err(dev, "no framebuffers found\n");
+		ret = -ENODEV;
 		goto err_alloc;
 	}
 
-- 
1.9.1


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

* Re: [PATCH] m501fb: don't return zero on failure path in sm501fb_probe()
  2014-10-31 22:40 [PATCH] m501fb: don't return zero on failure path in sm501fb_probe() Alexey Khoroshilov
@ 2014-11-06 14:22 ` Tomi Valkeinen
  0 siblings, 0 replies; 2+ messages in thread
From: Tomi Valkeinen @ 2014-11-06 14:22 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel,
	ldv-project

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

On 01/11/14 00:40, Alexey Khoroshilov wrote:
> If no framebuffers found, sm501fb_probe() breaks off initialization,
> deallocates sm501fb_info, but returns zero. As a result, use after free
> can happen in sm501fb_remove().
> 
> The patch adds -ENODEV as a return value in this case.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/video/fbdev/sm501fb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
> index 9e74e8fbe074..8b98b011fc04 100644
> --- a/drivers/video/fbdev/sm501fb.c
> +++ b/drivers/video/fbdev/sm501fb.c
> @@ -1988,6 +1988,7 @@ static int sm501fb_probe(struct platform_device *pdev)
>  	if (info->fb[HEAD_PANEL] == NULL &&
>  	    info->fb[HEAD_CRT] == NULL) {
>  		dev_err(dev, "no framebuffers found\n");
> +		ret = -ENODEV;
>  		goto err_alloc;
>  	}
>  
> 

Thanks, queued for 3.19.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2014-11-06 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31 22:40 [PATCH] m501fb: don't return zero on failure path in sm501fb_probe() Alexey Khoroshilov
2014-11-06 14:22 ` Tomi Valkeinen

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).