diff mbox

[v2] tgafb: potential NULL dereference in init

Message ID 20131216094922.GE13831@elgon.mountain (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Dec. 16, 2013, 9:49 a.m. UTC
Static checkers complain that there are paths where "tga_type_name" can
be NULL.  I've re-arranged the code slightly so that's impossible.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v1: had introduced a "dereferencing uninitialized variable" bug.  Thanks
to Geert Uytterhoeven for catching that.

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Tomi Valkeinen Jan. 10, 2014, 11:33 a.m. UTC | #1
On 2013-12-16 11:49, Dan Carpenter wrote:
> Static checkers complain that there are paths where "tga_type_name" can
> be NULL.  I've re-arranged the code slightly so that's impossible.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v1: had introduced a "dereferencing uninitialized variable" bug.  Thanks
> to Geert Uytterhoeven for catching that.
> 
> diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
> index f28674fea909..afd8887fd656 100644
> --- a/drivers/video/tgafb.c
> +++ b/drivers/video/tgafb.c
> @@ -1496,10 +1496,9 @@ tgafb_init_fix(struct fb_info *info)
>  		if (tga_bus_tc)
>  			tga_type_name = "Digital ZLX-E3";
>  		break;
> -	default:
> -		tga_type_name = "Unknown";
> -		break;
>  	}
> +	if (!tga_type_name)
> +		tga_type_name = "Unknown";
>  
>  	strlcpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
>  
> 

Queued for 3.14.

 Tomi
diff mbox

Patch

diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index f28674fea909..afd8887fd656 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -1496,10 +1496,9 @@  tgafb_init_fix(struct fb_info *info)
 		if (tga_bus_tc)
 			tga_type_name = "Digital ZLX-E3";
 		break;
-	default:
-		tga_type_name = "Unknown";
-		break;
 	}
+	if (!tga_type_name)
+		tga_type_name = "Unknown";
 
 	strlcpy(info->fix.id, tga_type_name, sizeof(info->fix.id));