Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1751799pxa; Thu, 6 Aug 2020 15:17:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPzGSBX7bCQU6YVvsYTZAM+z6u6Cpi7R1eQ3HNW3gV4UpY10OAth1fnwXhhYck+4zEAkAD X-Received: by 2002:a05:6402:1f8:: with SMTP id i24mr5954232edy.251.1596752251795; Thu, 06 Aug 2020 15:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596752251; cv=none; d=google.com; s=arc-20160816; b=rekJVDMjx7C+ScIrtJp75i48PMGB1qTwpuXL12SZCffQO1hcsCukkhTrgQXKxenlkA rlBAxbf+U3gVJHcyiW2D/y9HdiKU659PcWTj3q5ZQPZ+0vQ7ESL6wzuDgF+PT8tLxn0B QS7z21i1iC7Se3LJvg8Dh4gcInt9IXSkxCHn4nCvZSS3FQm8VGysRMt/h6pDN27SM303 mnOymUvgyG8LY6J/mtZnzPvqkoQNlqAt2xe3ewt8QwrbuEO6ATKjZHpVpgqY5t4TxoKw 3lP5s6OIdLuK9yoSWV/bW9pf/4+uDNh0S/zGIA3DsmpJIJfCv5TWFFDrsw/n1cPiLsJe AWIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=+OO3JBe6dnEY0FYNfFg4IfQrRwYMvznsaL2uMFXpIlc=; b=dNqwRjeehXUF075A/u+5gtHGWE6hMyhfu/RhiLr4Y8eOKYxvlf2O3raVy+jw6pRheu Th6qQ9nnyiCq7nZtxgFYmzOWjG+p0IiohysjW/sEn3FukfYXv5Hq1YCBjkcnr55UjT23 r3TI8lNHZthKdas7LrzsWLgfxgqSqXVBqW0CueB9WKwEkQSjGCEsaoHfc+hyeC4Qyywm RmSrym4ebWFf6Xk32ujm1nCb2kbGlmIbhK7wt2cVgw8FY7HZZ1xcq2QR2av1zdSEVrF7 kHcD52SIap64ezHW1y5aplDo/pgMKC1KoZdxc4YA3IT2KWptFUFSgRMqEWo3+sfcoP1P ggAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fhmU7icY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o2si4122039edj.268.2020.08.06.15.17.08; Thu, 06 Aug 2020 15:17:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fhmU7icY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728995AbgHFWPk (ORCPT + 99 others); Thu, 6 Aug 2020 18:15:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:47512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728986AbgHFWPk (ORCPT ); Thu, 6 Aug 2020 18:15:40 -0400 Received: from localhost (130.sub-72-107-113.myvzw.com [72.107.113.130]) (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 6FA49221E2; Thu, 6 Aug 2020 22:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596752139; bh=6V+A6F9WaUs3FGFH0cDcq6c0VYlcrNfuScxXobnpo3k=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fhmU7icYI+Tc7SdZpy0wowfM7RZbgqmTi3wJpP/mfqdrweNF2ylB0kgeJmvGZP+SC r6T8pC2+JbWbuIfXwHpyb7GEcnAV5L7TkPgsr2rCnf03hFchFiYc9G78EvO+K8Lugb sQim6ONph1cpwxAKr9aO6oLqE148o0w5L0GKqqtg= Date: Thu, 6 Aug 2020 17:15:37 -0500 From: Bjorn Helgaas To: Dan Carpenter Cc: Andy Shevchenko , "open list:STAGING SUBSYSTEM" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linux Kernel Mailing List , Sakari Ailus , Cengiz Can , Andy Shevchenko , Linux Media Mailing List Subject: Re: [PATCH] staging: atomisp: move null check to earlier point Message-ID: <20200806221537.GA703560@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200730084545.GB1793@kadam> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 30, 2020 at 11:45:45AM +0300, 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. > > I always feel like this is a pointless requirement. We're turning > into bureaucrats. There is a danger of that, and I'm more guilty than most. But I do think there's value in consistent style because it allows readers to focus on the content instead of being distracted by different margins, grammar ("move vs. moved"), paragraph styles, quoting conventions, etc. Ideally we would scan previous commit logs (and the existing code!) and make new changes fit seamlessly so it looks like everything was done at the same time by the same person. But often that doesn't happen. Sometimes I take the liberty to tweak things as I apply them to try to avoid trivial rework. Bjorn