Received: by 10.223.164.202 with SMTP id h10csp5539561wrb; Tue, 21 Nov 2017 11:18:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMYqWCPxz62IkoNWUcoPQllAefzArEKHWaHmw4v7fDGZRikD4i0ycjL+xhz6IzSWm1gazUIz X-Received: by 10.99.182.14 with SMTP id j14mr18080932pgf.116.1511291923643; Tue, 21 Nov 2017 11:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511291923; cv=none; d=google.com; s=arc-20160816; b=FAF2hIY+zBgZjyBo0KYkTm+TH7wec3ox8yKqmsEmxX+GThuHQ5B6UNE0knqobw9foK Tir6Um2ceVzbwVxvj1heLhaFjYwejyLftWqdrbOhLuBTwCyP4UEGAt+duUP4D6gEAfBS enQDfh+L+BZ+zQ/Qv0sFvnhwmtZ2sOM0jolKuwbGy5C27A1Xma19z0kNkIiw6xjCtGOV jTiqDAeo49DYkcN5uUFzPlVDM0wX9jiWY+oRkSuF4vMOZV2zePNHiZhrPT7y25atogo1 1CU12oUYo5Y3MJodufMxuC0thB8bv6dbp8kN6goRgEvM3EW4FaXful8nDgzrZT0iJslA CqaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=Ko7uuC0etv/YI7RnRqRYoHqUwpCN8yhousyhL60PQZw=; b=b8/7wl8ZlVnqmXgRDcaiKRbztA48gKqMxLKUNq+7azs/nSotvIOzu536obuQa1A/cA KhFpB1abUbazVCZBbXS3y2AHpII8S89zEUgRhII41ijls4j5twQK4y5GQwjmTSSAURQv 7J0ajUvyaqj5uG0moQXw399+N8UTXS2VxsgOSRzaZ/BJWnVBJjzvS6cksiGhRsaGc0Ao jZcIk9jPQyAHA9jTgXMQvMqMgKLaAdy2OLX9LZdwkQwQeVVheZsgZZpI7XvG2mJpcfRf vFykaQXxXLMe2t7wU4aeubJdGLjdnSlGgCPP8YxY4KWm5xbJqmtFl1Hl6lkKC5uMnhNG KVSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Pi7n2xrO; dkim=pass header.i=@codeaurora.org header.s=default header.b=iZ4Q/rys; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r74si12907223pfe.273.2017.11.21.11.18.32; Tue, 21 Nov 2017 11:18:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Pi7n2xrO; dkim=pass header.i=@codeaurora.org header.s=default header.b=iZ4Q/rys; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbdKUTQS (ORCPT + 76 others); Tue, 21 Nov 2017 14:16:18 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:53322 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751316AbdKUTQQ (ORCPT ); Tue, 21 Nov 2017 14:16:16 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 38FD16024A; Tue, 21 Nov 2017 19:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511291776; bh=8cWC1mqtD0jhAJMJEMuwi7I/JVvnMwuGistfJdnQ/Tg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Pi7n2xrO9RxK4laoT2TwV0zdTdyMYDMGF/xpF6pISfJDYQ9UzGd4+uMAeFTSI3X6W Ft30C24IS3kBMaUtRuy8Wco//EKvPSohrODzDKwZ1KwDYLllhME40kvQzp9eh2w9fw SnGKzsImVQ+XIU0fvwIkH8dRKt/IHdes6WscYuKY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 79FDE6024A; Tue, 21 Nov 2017 19:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511291775; bh=8cWC1mqtD0jhAJMJEMuwi7I/JVvnMwuGistfJdnQ/Tg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iZ4Q/rys9k4cIrFyTsgweuJ7YY0UDHcvFcyTGRmnsJTcH8bJ2xeN7+NVDSDpZBUoT kNJrNbKTxIKPYQEe/mzNCRtJe3dKsp8jsVHFQR5/jutNclFJv02mOcRY17E1ygatgS J/QesoobbJsyvieXn25dkDa3eNq4+JfMWEN3chxw= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 21 Nov 2017 11:16:15 -0800 From: Subhash Jadavani To: "Gustavo A. R. Silva" Cc: Vinayak Holikatti , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi-owner@vger.kernel.org Subject: Re: [PATCH] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg In-Reply-To: <20171120141229.GA2130@embeddedor.com> References: <20171120141229.GA2130@embeddedor.com> Message-ID: X-Sender: subhashj@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017-11-20 06:12, Gustavo A. R. Silva wrote: > _vreg_ is being dereferenced before it is null checked, hence there is > a > potential null pointer dereference. > > Fix this by moving the pointer dereference after _vreg_ has been null > checked. > > This issue was detected with the help of Coccinelle. > > Fixes: aa4976130934 ("ufs: Add regulator enable support") > Signed-off-by: Gustavo A. R. Silva > --- > drivers/scsi/ufs/ufshcd.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 011c336..a355d98 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -6559,12 +6559,15 @@ static int ufshcd_config_vreg(struct device > *dev, > struct ufs_vreg *vreg, bool on) > { > int ret = 0; > - struct regulator *reg = vreg->reg; > - const char *name = vreg->name; > + struct regulator *reg; > + const char *name; > int min_uV, uA_load; > > BUG_ON(!vreg); > > + reg = vreg->reg; > + name = vreg->name; > + > if (regulator_count_voltages(reg) > 0) { > min_uV = on ? vreg->min_uV : 0; > ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); Looks good to me. Reviewed-by: Subhash Jadavani -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project From 1584594679115361987@xxx Mon Nov 20 14:14:07 +0000 2017 X-GM-THRID: 1584594679115361987 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread