diff mbox

video:uvesafb: Fix dereference NULL pointer code path

Message ID 20130330025330.GA25246@udknight (mailing list archive)
State New, archived
Headers show

Commit Message

wang yanqing March 30, 2013, 2:53 a.m. UTC
platform_device_alloc could failed and return NULL,
we should check this before call platform_device_put.

Signed-off-by: Wang YanQing <udknight@gmail.com>
---
 drivers/video/uvesafb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tomi Valkeinen April 2, 2013, 10:34 a.m. UTC | #1
On 2013-03-30 04:53, Wang YanQing wrote:
> platform_device_alloc could failed and return NULL,
> we should check this before call platform_device_put.
> 
> Signed-off-by: Wang YanQing <udknight@gmail.com>
> ---
>  drivers/video/uvesafb.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
> index 2f8f82d..230bd45 100644
> --- a/drivers/video/uvesafb.c
> +++ b/drivers/video/uvesafb.c
> @@ -1975,7 +1975,8 @@ static int __devinit uvesafb_init(void)
>  			err = -ENOMEM;
>  
>  		if (err) {
> -			platform_device_put(uvesafb_device);
> +			if (uvesafb_device)
> +				platform_device_put(uvesafb_device);
>  			platform_driver_unregister(&uvesafb_driver);
>  			cn_del_callback(&uvesafb_cn_id);
>  			return err;
> 

Thanks, queued to fbdev fixes.

 Tomi
diff mbox

Patch

diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 2f8f82d..230bd45 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -1975,7 +1975,8 @@  static int __devinit uvesafb_init(void)
 			err = -ENOMEM;
 
 		if (err) {
-			platform_device_put(uvesafb_device);
+			if (uvesafb_device)
+				platform_device_put(uvesafb_device);
 			platform_driver_unregister(&uvesafb_driver);
 			cn_del_callback(&uvesafb_cn_id);
 			return err;