Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2718360pxu; Mon, 14 Dec 2020 09:15:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7+CgXqqR2nRvru398I5VmCwuY8hvQq2SoBmBpQIngMQC798twjR+dEKQiLNw7wXV58FMB X-Received: by 2002:a17:907:214d:: with SMTP id rk13mr2081942ejb.501.1607966131323; Mon, 14 Dec 2020 09:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607966131; cv=none; d=google.com; s=arc-20160816; b=WB4JHTA9BEXJLyQKrqgQLCVabs9eLnMMW5XO8XlxEzU6vXTnhmks+eWa8u+xwyCNZ9 cyhALGrcyiKVI85uE/+nBDi9Mtf3RLuX2OhoANQ7RhvdP1IU/cR7BHA4BL8bx9G1q0aG AnnH6T6BvAdk3Jm2oBnjHDNCHcdAGpCRUK4chAL7ttZhxLGY4Chd2yNCrcbKF4oFroUa fu97ddnd7iuLXDwZqU1YcwfKi4WaYTnstqW2IGsfSsV1WhEbRxt5FYuvkqlavz5G+HAZ OG1F3AkwauvsSUHxBbw3Poz9cNbD0zDmGmkxVxURKpXwQNVEgK08TeXvS2sXnsK56KIS 2Utw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr; bh=NUyeaex3ifAR14OwyUB02l/Cb3vTdO4lcmms9idSqoM=; b=mAem/o84SEDI4j0A7njucBA0x+Xk5MnLAPSpmh+jF120ErKo9oUAyjUqvJ+D7f4kf0 M3LHkDNagZX8lj+0bnINckpAXAQ/5UDizdGNMThD+UFou0e8nOLVYEpkUgv9G8NAE1Ts thnrI3WSU92d3KUpE4/sftRr/pIF3DGsJ+b72IEXeU0UOv8x22nFqNLRCmhdMoOSTV/E XRwfPHQsdZ82b9e/4V4/MjmYhDITTBkFbz+1DZvVOLjEKp88SyDwzqLwbkh89aJv3KEy n0iEbUdSJQxhWQPYgxWbK1UETkJs1N+qxlaeOxfgzDA110buQ5QT4JjPGKBH0P8zi5hk cMcg== ARC-Authentication-Results: i=1; mx.google.com; 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 o16si10361982ejx.217.2020.12.14.09.14.57; Mon, 14 Dec 2020 09:15:31 -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; 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 S2438442AbgLNDmm (ORCPT + 99 others); Sun, 13 Dec 2020 22:42:42 -0500 Received: from labrats.qualcomm.com ([199.106.110.90]:1081 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438375AbgLNDmZ (ORCPT ); Sun, 13 Dec 2020 22:42:25 -0500 IronPort-SDR: CNPjLB8U2r0Fgtaiknb/rAw4D8FmB18qWG1Z+oI3KGyXu5dOre4CcWcBl+6zAoMIHjIG2/zobi w4UC+FvyojqDARC7BXatwLvL/BUO7/6iCowmpsLeiFB8Qjrv+uaNcy0AKCQeNpZQGxG8DqwhLi tR7kK7RDVtClPBmvM0pvp1cmu4iMFcOxY55vQKtDcZno5BSzyMxVv2i4PScUg354Yur6WwClkq WE/en/jSYD/ycr/DReIoEzW6ss31Mlv450WSca7GgluiL/vxQMc6jJjvtFueKK0fG0BjImswA2 w1A= X-IronPort-AV: E=Sophos;i="5.78,417,1599548400"; d="scan'208";a="47581862" Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by labrats.qualcomm.com with ESMTP; 13 Dec 2020 19:41:39 -0800 X-QCInternal: smtphost Received: from wsp769891wss.qualcomm.com (HELO stor-presley.qualcomm.com) ([192.168.140.85]) by ironmsg-SD-alpha.qualcomm.com with ESMTP; 13 Dec 2020 19:41:38 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 9D20221216; Sun, 13 Dec 2020 19:41:38 -0800 (PST) From: Can Guo To: 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, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 1/1] scsi: ufs: Fix a possible NULL pointer issue Date: Sun, 13 Dec 2020 19:41:32 -0800 Message-Id: <1607917296-11735-1-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During system resume/suspend, hba could be NULL. In this case, do not touch eh_sem. 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; if ((ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl) == @@ -8932,10 +8935,8 @@ int ufshcd_system_resume(struct ufs_hba *hba) int ret = 0; ktime_t start = ktime_get(); - if (!hba) { - up(&hba->eh_sem); + if (!hba) return -EINVAL; - } if (!hba->is_powered || pm_runtime_suspended(hba->dev)) /* -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.