From patchwork Mon Dec 16 09:49:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 3352691 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 836E49F32E for ; Mon, 16 Dec 2013 09:53:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5864520270 for ; Mon, 16 Dec 2013 09:53:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB43920266 for ; Mon, 16 Dec 2013 09:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751848Ab3LPJw7 (ORCPT ); Mon, 16 Dec 2013 04:52:59 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:28469 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995Ab3LPJw6 (ORCPT ); Mon, 16 Dec 2013 04:52:58 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBG9oETd022835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 16 Dec 2013 09:50:16 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBG9o9PV023532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Dec 2013 09:50:13 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBG9o9A7002148; Mon, 16 Dec 2013 09:50:09 GMT Received: from elgon.mountain (/41.202.233.184) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Dec 2013 01:50:08 -0800 Date: Mon, 16 Dec 2013 12:49:23 +0300 From: Dan Carpenter To: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen , linux-fbdev@vger.kernel.org, kernel-janitors@vger.kernel.org, Geert Uytterhoeven Subject: [patch v2] tgafb: potential NULL dereference in init Message-ID: <20131216094922.GE13831@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 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));