Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5191055pxj; Wed, 9 Jun 2021 11:15:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqs5L9iG/W1lL1qsr+XmtiVAgYxHfy0FS6ehB6gAJF6sg1Kf4iaSSmG6n2ce02cAIRabAj X-Received: by 2002:a17:906:2854:: with SMTP id s20mr1042012ejc.335.1623262536500; Wed, 09 Jun 2021 11:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623262536; cv=none; d=google.com; s=arc-20160816; b=O8KzIw7kD0U3D/tRVl5hjkzJxFcJLKNpnZ/+qJxOzjeJPFgPo4s7c1OMAzm5r8CBH4 v1tI3EesxLddRk0BZRAdOyNeT3tzYeRFUaq5k/1rXgK/p2d2lv8weSu7O1VwYN7JgdHq 4S3kDmfHjFTPyvfM61S1ae/padB9zYwHLoRSLoQ4ybFMlkbaxjEA+tOcnURVTibVHZoH 7eD4GkajONzbFWAeb17AfroqrchKAwTJ2YN8AktMEZRa9DxW44GSqb1u0ncdK4rKcFlU ViWj+1S7AcJBUWnLrLUEKHpzoleKnmgpeR2IwxFVAi1ne6HAiVAczMFax+eYYU1QABTa t7QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4XQjEKcC46jA0hTXRk94caAMc0m0fkzAeAS4/x05Ps4=; b=ZcuizCf9Ln8r5D6xeaufVJGrBXqW1XnWipE/5qPccwbkeq62TnGdE25xpkz2pzgRCs qEjRuS5ft3vHtYKuUlzQ1mo+u3QHu2ufj3pHHCzQfLZ/ulHRGcAZne9m6YfkW2inCFZx X2Dzjpup2nmspqfAiJizF7aCjzQ2by8Nvmne77Gl0i5qgDdpcnhIYxyw4kARr4VOv2g1 SMP89liCdr9dUGlO+dylZI6ngoQSktepawOPBSmR1KZcCOoCDGSu2SaxW+MEj+9v25nn 9JuMLa/pWlQJwS8wPwkrebAl4aG/Enh1MK91VMiVdmhnQLVBg7y/tQS9K3/gjybPvzwH E9BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NLOK9mUD; 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 a26si321602edt.163.2021.06.09.11.15.06; Wed, 09 Jun 2021 11:15:36 -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=k20201202 header.b=NLOK9mUD; 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 S231513AbhFIR2c (ORCPT + 99 others); Wed, 9 Jun 2021 13:28:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbhFIR2b (ORCPT ); Wed, 9 Jun 2021 13:28:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E00A60FF0; Wed, 9 Jun 2021 17:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623259597; bh=FpoCLV9AugRc/VDev7vPQc6huezBsa4q91oamgMCi5c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NLOK9mUD+/TKJsoyTz8L0eBkVX43pGvWLc5FpY6jTYXm9zQH9xDeb8eVBxYr7141D oOihLl1UDsYd8WcVKymY7cYRTAlm3IBdGHGVhpv44a485uzGP1mU2iQkVxmZiW6Yrr CYpWet4OJByewcGJb/e+Cvsm73g/rtgPybRmUxF8PG+VXeTf6OD/vvfSdsYhqew/B4 C0t3li6a730oPWMd8/cLa8kLP3IXqdVjxFEe9oxvSmIAfWpXEc7rcRa8D36ghB0lqZ Z36gt8FMHm2fGxJbUpKIFxdjCg1lUZChHzTVUM7Jf/XD/gFw/osviQV2csVEl4jxOF 21rQWy31RN3pg== Date: Wed, 9 Jun 2021 10:26:30 -0700 From: Nathan Chancellor To: Can Guo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, ziqichen@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Matthias Brugger , Stanley Chu , Bean Huo , Jaegeuk Kim , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Subject: Re: [PATCH v3] scsi: ufs: Fix a possible use before initialization case Message-ID: References: <1623227044-22635-1-git-send-email-cang@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1623227044-22635-1-git-send-email-cang@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 09, 2021 at 01:24:00AM -0700, Can Guo wrote: > In ufshcd_exec_dev_cmd(), if error happens before lrpb is initialized, > then we should bail out instead of letting trace record the error. > > Fixes: a45f937110fa6 ("scsi: ufs: Optimize host lock on transfer requests send/compl paths") > Reported-by: kernel test robot > Reviewed-by: Stanley Chu > Signed-off-by: Can Guo Reviewed-by: Nathan Chancellor > --- > > Change since V2: > - Removed unused goto out_put_tag > > Change since V1: > - Use codeaurora mail in Signed-off-by tag > > drivers/scsi/ufs/ufshcd.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index fe1b5f4..25fe18a 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -2980,7 +2980,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, > WARN_ON(lrbp->cmd); > err = ufshcd_compose_dev_cmd(hba, lrbp, cmd_type, tag); > if (unlikely(err)) > - goto out_put_tag; > + goto out; > > hba->dev_cmd.complete = &wait; > > @@ -2990,11 +2990,10 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, > > ufshcd_send_command(hba, tag); > err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout); > -out: > ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP, > (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); > > -out_put_tag: > +out: > blk_put_request(req); > out_unlock: > up_read(&hba->clk_scaling_lock); > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project. >