From patchwork Wed Sep 2 16:10:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11751163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DD4614E3 for ; Wed, 2 Sep 2020 16:13:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8D002072A for ; Wed, 2 Sep 2020 16:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599063179; bh=Bybq2rNfz8+YFu+79t9vTEYCcLnK9U6RRVeZrJpy54M=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=t1R3sGbQCdddFsMGnMqcYBRj7S9gie5u6IutXpu21WksuRVG9UcPffw83Ib9pLtBm knQO+So8zMFd10pRInmJbM4iZbamxnjIZ0COVem7G3b9J2N0a5A8EruNpp/jY22csr HHqqiBcul9VrtAwwU2Yfw7YcFbQCsICRI1bmTtlI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728578AbgIBQMi (ORCPT ); Wed, 2 Sep 2020 12:12:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728356AbgIBQLB (ORCPT ); Wed, 2 Sep 2020 12:11:01 -0400 Received: from mail.kernel.org (ip5f5ad5c3.dynamic.kabel-deutschland.de [95.90.213.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B7F92221EE; Wed, 2 Sep 2020 16:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599063046; bh=Bybq2rNfz8+YFu+79t9vTEYCcLnK9U6RRVeZrJpy54M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zH/UCAIh8bJ9EuRI41MVaF3pj51wP/SxGs/N8KbuRrylHJyFovC5ocPUUQCVEpLo/ fr3wQ0HUKt/nzEp7Jx5gJU+a251Y2RQwY58GYhJBqLZjNfCbB3bZHOYdjDtfvnxgCn UM1YrCjIzdOCDEruGClldRk3AxV16j9CgNNrxObU= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kDVLQ-000tBP-Sq; Wed, 02 Sep 2020 18:10:44 +0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Andy Shevchenko , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 37/38] media: atomisp: atomisp_gmin_platform: check before use Date: Wed, 2 Sep 2020 18:10:40 +0200 Message-Id: <7778f1f6c8cbc303f6f7377e0daca28a6825f862.1599062230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.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 solve this smatch warning: drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c:842 gmin_v1p8_ctrl() warn: variable dereferenced before check 'gs' (see line 832) By moving the check to happen before its usage. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index c49d27038d27..8652f71dfff6 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -829,6 +829,9 @@ static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on) int ret; int value; + if (!gs || gs->v1p8_on == on) + return 0; + if (gs->v1p8_gpio >= 0) { pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n", gs->v1p8_gpio); @@ -839,8 +842,6 @@ static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on) pr_err("V1P8 GPIO initialization failed\n"); } - if (!gs || gs->v1p8_on == on) - return 0; gs->v1p8_on = on; if (gs->v1p8_gpio >= 0)