From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DE51C433E1 for ; Thu, 30 Jul 2020 08:59:23 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2020F2075F for ; Thu, 30 Jul 2020 08:59:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2020F2075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.wtf Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id EB6E686975; Thu, 30 Jul 2020 08:59:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4H_pyFv3HvBN; Thu, 30 Jul 2020 08:59:22 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3F2D78694A; Thu, 30 Jul 2020 08:59:22 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 2194B1BF345 for ; Thu, 30 Jul 2020 08:59:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 1DE628805C for ; Thu, 30 Jul 2020 08:59:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RJ-rkMKlaKdy for ; Thu, 30 Jul 2020 08:59:19 +0000 (UTC) X-Greylist: delayed 19:01:31 by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by whitealder.osuosl.org (Postfix) with ESMTPS id 4C677882E1 for ; Thu, 30 Jul 2020 08:59:18 +0000 (UTC) X-Originating-IP: 176.88.148.196 Received: from [192.168.1.3] (unknown [176.88.148.196]) (Authenticated sender: cengiz@kernel.wtf) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 9FA0C24000C; Thu, 30 Jul 2020 08:59:13 +0000 (UTC) From: Cengiz Can To: Dan Carpenter , Andy Shevchenko Date: Thu, 30 Jul 2020 11:59:10 +0300 Message-ID: <1739ef25b30.2bfa.85c738e3968116fc5c0dc2de74002084@kernel.wtf> In-Reply-To: <20200730084545.GB1793@kadam> References: <20200729135636.9220-1-cengiz@kernel.wtf> <20200730084545.GB1793@kadam> User-Agent: AquaMail/1.25.2-1666 (build: 102500007) Subject: Re: [PATCH] staging: atomisp: move null check to earlier point MIME-Version: 1.0 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:STAGING SUBSYSTEM" , Andy Shevchenko , Greg Kroah-Hartman , Linux Kernel Mailing List , Sakari Ailus , Mauro Carvalho Chehab , Linux Media Mailing List Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" On July 30, 2020 11:48:06 Dan Carpenter wrote: > On Wed, Jul 29, 2020 at 06:13:44PM +0300, Andy Shevchenko wrote: >> On Wed, Jul 29, 2020 at 5:00 PM Cengiz Can wrote: >>> >>> `find_gmin_subdev` function that returns a pointer to `struct >>> gmin_subdev` can return NULL. >>> >>> In `gmin_v2p8_ctrl` there's a call to this function but the possibility >>> of a NULL was not checked before its being dereferenced. ie: >>> >>> ``` >>> /* Acquired here --------v */ >>> struct gmin_subdev *gs = find_gmin_subdev(subdev); >>> int ret; >>> int value; >>> >>> /* v------Dereferenced here */ >>> if (gs->v2p8_gpio >= 0) { >>> pr_info("atomisp_gmin_platform: 2.8v power on GPIO %d\n", >>> gs->v2p8_gpio); >>> ret = gpio_request(gs->v2p8_gpio, "camera_v2p8"); >>> if (!ret) >>> ret = gpio_direction_output(gs->v2p8_gpio, 0); >>> if (ret) >>> pr_err("V2P8 GPIO initialization failed\n"); >>> } >>> ``` >>> >>> I have moved the NULL check before deref point. >> >> "Move the NULL check..." >> See Submitting Patches documentation how to avoid "This patch", "I", "we", etc. Noted. Sorry. I'm not a native English speaker. >> > > I always feel like this is a pointless requirement. We're turning into > bureaucracts. > >> >>> diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c >>> b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c >>> index 0df46a1af5f0..8e9c5016f299 100644 >>> --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c >>> +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c >>> @@ -871,6 +871,11 @@ static int gmin_v2p8_ctrl(struct v4l2_subdev *subdev, >>> int on) >>> int ret; >>> int value; >>> >>> + if (!gs) { >>> + pr_err("Unable to find gmin subdevice\n"); >> >>> + return -EINVAL; >> >> And here is a change of semantics... > > Yeah. The change of semantics should be documented in the commit > message, but it's actually correct. I discussed this with Mauro earlier > but my bug reporting script didn't CC a mailing list and I didn't > catch it. Mauro suggested: > > 53 > Yet, it could make sense to have something like: > 54 > > 55 > if (WARN_ON(!gs)) > 56 > return -ENODEV; > 57 > > 58 > at the beginning of the functions that call find_gmin_subdev(). I will be updating v2 according to this. > > regards, > dan carpenter _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel