From patchwork Wed Sep 25 09:36:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 2941221 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 93C1A9F288 for ; Wed, 25 Sep 2013 09:39:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7412F20582 for ; Wed, 25 Sep 2013 09:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 418EE2057D for ; Wed, 25 Sep 2013 09:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754912Ab3IYJjT (ORCPT ); Wed, 25 Sep 2013 05:39:19 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:41715 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755015Ab3IYJjO (ORCPT ); Wed, 25 Sep 2013 05:39:14 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r8P9aTFb023907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Sep 2013 09:36:29 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8P9aSHs009460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 25 Sep 2013 09:36:28 GMT Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8P9aRVV018509; Wed, 25 Sep 2013 09:36:27 GMT Received: from mwanda (/41.210.129.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2013 02:36:26 -0700 Date: Wed, 25 Sep 2013 12:36:12 +0300 From: Dan Carpenter To: Richard Purdie , "'Andrew Morton'" Cc: Jingoo Han , "'Daniel Jeong'" , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch 2/2] backlight: lm3630: potential NULL deref in probe() Message-ID: <20130925093612.GR6192@mwanda> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <002101ceb9cf$7f773250$7e6596f0$%han@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-8.9 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 We dereference "pdata" later in the function so we can't leave it as NULL. Signed-off-by: Dan Carpenter Acked-by: Jingoo Han --- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- 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/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 65392f9..6146481 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -389,22 +389,21 @@ static int lm3630a_probe(struct i2c_client *client, i2c_set_clientdata(client, pchip); if (pdata == NULL) { - pchip->pdata = devm_kzalloc(pchip->dev, - sizeof(struct - lm3630a_platform_data), - GFP_KERNEL); - if (pchip->pdata == NULL) + pdata = devm_kzalloc(pchip->dev, + sizeof(struct lm3630a_platform_data), + GFP_KERNEL); + if (pdata == NULL) return -ENOMEM; /* default values */ - pchip->pdata->leda_ctrl = LM3630A_LEDA_ENABLE; - pchip->pdata->ledb_ctrl = LM3630A_LEDB_ENABLE; - pchip->pdata->leda_max_brt = LM3630A_MAX_BRIGHTNESS; - pchip->pdata->ledb_max_brt = LM3630A_MAX_BRIGHTNESS; - pchip->pdata->leda_init_brt = LM3630A_MAX_BRIGHTNESS; - pchip->pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS; - } else { - pchip->pdata = pdata; + pdata->leda_ctrl = LM3630A_LEDA_ENABLE; + pdata->ledb_ctrl = LM3630A_LEDB_ENABLE; + pdata->leda_max_brt = LM3630A_MAX_BRIGHTNESS; + pdata->ledb_max_brt = LM3630A_MAX_BRIGHTNESS; + pdata->leda_init_brt = LM3630A_MAX_BRIGHTNESS; + pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS; } + pchip->pdata = pdata; + /* chip initialize */ rval = lm3630a_chip_init(pchip); if (rval < 0) {