From patchwork Fri May 4 15:18:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10380849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12B0B6038F for ; Fri, 4 May 2018 15:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B064E293D3 for ; Fri, 4 May 2018 15:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3D2D29447; Fri, 4 May 2018 15:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 502812930A for ; Fri, 4 May 2018 15:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751401AbeEDPST (ORCPT ); Fri, 4 May 2018 11:18:19 -0400 Received: from osg.samsung.com ([64.30.133.232]:39538 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751301AbeEDPSS (ORCPT ); Fri, 4 May 2018 11:18:18 -0400 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 4177A1EBEA; Fri, 4 May 2018 08:18:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Tn1LjhT2wlB; Fri, 4 May 2018 08:18:16 -0700 (PDT) Received: from smtp.s-opensource.com (177.17.129.114.dynamic.adsl.gvt.net.br [177.17.129.114]) by osg.samsung.com (Postfix) with ESMTPSA id 9A52B1EBDF; Fri, 4 May 2018 08:18:16 -0700 (PDT) Received: from mchehab by smtp.s-opensource.com with local (Exim 4.90_1) (envelope-from ) id 1fEcTO-0007oQ-DL; Fri, 04 May 2018 11:18:14 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH] media: lgdt330x: don't use an uninitialized state Date: Fri, 4 May 2018 11:18:13 -0400 Message-Id: <89eaaf2d19a6cfff0a16014405c2a65b5257b8a1.1525447090.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.17.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If state is not initialized or is freed, we can't use it: drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: potential null dereference 'state'. (kzalloc returns null) drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: we previously assumed 'state' could be null (see line 878) drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: dereferencing freed memory 'state' Fixes: 23ba635d45f5 ("media: lgdt330x: convert it to the new I2C binding way") Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/lgdt330x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c index 927fd68e05ec..f6731738b073 100644 --- a/drivers/media/dvb-frontends/lgdt330x.c +++ b/drivers/media/dvb-frontends/lgdt330x.c @@ -917,7 +917,8 @@ static int lgdt330x_probe(struct i2c_client *client, error: kfree(state); - dprintk(state, "ERROR\n"); + if (debug) + dev_printk(KERN_DEBUG, &client->dev, "Error loading lgdt330x driver\n"); return -ENODEV; } struct dvb_frontend *lgdt330x_attach(const struct lgdt330x_config *_config,