From patchwork Mon Aug 26 14:56:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 2849615 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 06CFD9F271 for ; Mon, 26 Aug 2013 14:59:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B93A72018B for ; Mon, 26 Aug 2013 14:59:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85BA92013B for ; Mon, 26 Aug 2013 14:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756791Ab3HZO64 (ORCPT ); Mon, 26 Aug 2013 10:58:56 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:20791 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756765Ab3HZO6z (ORCPT ); Mon, 26 Aug 2013 10:58:55 -0400 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 r7QEuMKE023308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Aug 2013 14:56:23 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 r7QEuK1a025813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 26 Aug 2013 14:56:21 GMT Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7QEuK5B018268; Mon, 26 Aug 2013 14:56:20 GMT Received: from elgon.mountain (/41.210.129.11) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2013 07:56:19 -0700 Date: Mon, 26 Aug 2013 17:56:10 +0300 From: Dan Carpenter To: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen , linux-fbdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] tgafb: potential NULL dereference in init Message-ID: <20130826145610.GA12428@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline 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=-9.3 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 --- 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 c9c8e5a..2dcaf2e 100644 --- a/drivers/video/tgafb.c +++ b/drivers/video/tgafb.c @@ -1475,7 +1475,7 @@ tgafb_init_fix(struct fb_info *info) int tga_bus_pci = TGA_BUS_PCI(par->dev); int tga_bus_tc = TGA_BUS_TC(par->dev); u8 tga_type = par->tga_type; - const char *tga_type_name = NULL; + const char *tga_type_name; switch (tga_type) { case TGA_TYPE_8PLANE: @@ -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));