Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1831860pxu; Thu, 17 Dec 2020 21:47:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRT9yQ263Rw8qMapvtTkZq6Fn9lE46ESIbz+VP15tZ8+ONBCM9hxP8oidWQYFMR3/mIm7K X-Received: by 2002:a05:6402:1a2f:: with SMTP id be15mr2757812edb.209.1608270469072; Thu, 17 Dec 2020 21:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608270469; cv=none; d=google.com; s=arc-20160816; b=vsHKVckuIc52iF8eZomqORxjIg0JwfCTVKfTYUUMKPuks4EVpDV4JXlr+broPFm6XE tAKSQsYsVUlB1+B8/G1ll6AYOW79TZjEe58BTI/duhzxrkk3Af+ydiXycWw598mMhx8p QnztzZCpTvfmattEtjavRy9OFOnY1qdM+/w9ttbk/TtN9cytw6CtxMJ1OXcL/cH5jFXg HHjp+7HHlkW1XCPwMETkYM9hNpWyPyjEBzpif2EY75DbERaA4Qlsz9BB5aliTygDUzpK Y3eVakoSkYDBvzcOtoGUI6QaBF4ZXyre7zp4T+FB+M4Wcsu6qbJFjShkdmwn+P+fxsX5 /3fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=OwsFRegftF2w32/gXog44MqpD2EZ8WZconOVWoSuFSw=; b=ybY7qx9N9TXEhJySgYB3cHUui/Pvq5LSYRJYwTWBgExANtWnXUuvHadbRROS07g5Oi d2gpft+x/WFLhQOdn0EIneGu4gYoj04pqHyAcfXDnr7Qwad8321Ne2ErdEyJXro1T0qW xo15qgFvFexMjJ6yDDKTOmoaGek7PbWIAAMhUfgjsX/kIDD9rYWAjMKSHZSS2eoJ5J/I ctA7Sf/iLFEg/0ZwY0feNuaALM7bCrzusUvf4OT3j8/H5hms7eyMbrrzgKZlN/y5zVu0 xxFdzaPCE5UzxBxq5lAjhyozUYMw/c0U/vfAdUwMuwz8NCjhUP8Q8WYGC2KXyxejVs1G dKDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=UJYARiWe; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si5737326edn.225.2020.12.17.21.47.26; Thu, 17 Dec 2020 21:47:49 -0800 (PST) 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=@mg.codeaurora.org header.s=smtp header.b=UJYARiWe; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730483AbgLRFne (ORCPT + 99 others); Fri, 18 Dec 2020 00:43:34 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:25178 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbgLRFne (ORCPT ); Fri, 18 Dec 2020 00:43:34 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1608270188; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=OwsFRegftF2w32/gXog44MqpD2EZ8WZconOVWoSuFSw=; b=UJYARiWevxuCOvyyJbvpfNw5gF79N/eID1uX6nkVg3OXv7oE0eN+Ydpwjz7F1xLC991IWHbS zr6tqvDQyKDBSp2M7H3WZqaCRFbz3IioTN5Y9UDVrEKJifHZyX8cGaijL+6kJdxaoTvxY/v6 Aahu9kfYuK0wJVVxGmVaBMGmfe8= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n08.prod.us-east-1.postgun.com with SMTP id 5fdc414d7549779c5b7b5875 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 18 Dec 2020 05:42:37 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CB450C43467; Fri, 18 Dec 2020 05:42:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id E016BC433CA; Fri, 18 Dec 2020 05:42:35 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 18 Dec 2020 13:42:35 +0800 From: Can Guo To: Bean Huo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , open list Subject: Re: [PATCH V2 1/1] scsi: ufs: Fix a possible NULL pointer issue In-Reply-To: <7eb8f335f4eb85385f54c88952f7749750340320.camel@gmail.com> References: <1607917296-11735-1-git-send-email-cang@codeaurora.org> <7eb8f335f4eb85385f54c88952f7749750340320.camel@gmail.com> Message-ID: <44d4f6349b7c8d806871acbe22c2bcce@codeaurora.org> X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-12-14 22:32, Bean Huo wrote: > On Sun, 2020-12-13 at 19:41 -0800, Can Guo wrote: >> Fixes: 88a92d6ae4fe ("scsi: ufs: Serialize eh_work with system PM >> events and async scan") >> >> Signed-off-by: Can Guo >> --- >> drivers/scsi/ufs/ufshcd.c | 9 +++++---- >> 1 file changed, 5 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index c1c401b..ef155a9 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -8883,8 +8883,11 @@ int ufshcd_system_suspend(struct ufs_hba *hba) >> int ret = 0; >> ktime_t start = ktime_get(); >> >> + if (!hba) >> + return 0; >> + >> down(&hba->eh_sem); >> - if (!hba || !hba->is_powered) >> + if (!hba->is_powered) >> return 0; > > > Can, > > why not moving down(&hba->eh_sem) after "return 0;"? In your way, if hba is not powered, ufshcd_system_suspend() returns 0, which is a successful suspend. When ufshcd_system_resume() is called, if hba is not powered, it goes to out and does up(&hba->eh_sem), which shall cause unbalance to eh_sem. Thanks, Can Guo.