Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1049230pxb; Sat, 16 Oct 2021 00:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9YCbyihxnxWE4MvC21xwRX8E7Bt+w26uRagQq6twnGX5t8yR+hw0h39vPUSSGFZ0yTQqC X-Received: by 2002:a17:906:4d19:: with SMTP id r25mr12340043eju.264.1634367620462; Sat, 16 Oct 2021 00:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634367620; cv=none; d=google.com; s=arc-20160816; b=O7/3FZjqgl1pfIGWTB/0DlbZhr8nhD7hFXtVIXhEx0cQulBE4kmmV8NmNEFzmd2US0 vwpzepHxrVQMDauQUbPjd0LwBnDKNCnaWENab//684NvWRp0mB3+hP+exMoPunPm9W6t DrnDCHrsrTLr6OGdIi5JROGxRS/6H+VWe7+DryxmLnd5wGRXqbYRLpWxGQsd/se38Gas hQsFSgkEalroK4oDL/AOk07HXXsipeYweSBdqfiQUt/KqJ7VkylNDH4I2Z0vtNi1m4a2 pTZm9VkEM++ULhCXn1QuHfEHTfQ7SEgggQgwwgdmH3cRh9wsB1BA3KjIgPI77hbwqbBu Nxnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=bwQycHhCD3SRrG+t7KjQ+HRY70mGyvy4NaTIJH8kqts=; b=bAYg7NgqIgpdGWfD0UmGnqfdc2cKMqPkMhb+w5h1VqjLhg0eQ1yCyJit/iWbqPfL14 cwGfWG+++GFh4CIplfg7E3jJNKWXm2QauQeqAI4cRcLTP6MVcMxN8SfwPiXwanafYwU+ ZoYTZfh62+wp0tMfVQSc76NVzGQNxrhpcOfsbLX0n1w5THsKITyHKBkRBwLaAHMypub4 TzkuE8PTi9yJqcRbxarR1yRTpWo0yERbJsC58j3wxk/ENSOD6GL9qOgCW0C5kS5E1TT6 q3H7dkUBKnH+yMiXmEG95+1NLCV4hklqv2H969BBViqspJoVLCdTohJqI1AbkBGJW4gA CvHg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 14si10653719ejj.313.2021.10.15.23.59.57; Sat, 16 Oct 2021 00:00:20 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235136AbhJONfT (ORCPT + 99 others); Fri, 15 Oct 2021 09:35:19 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:54288 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234697AbhJONfS (ORCPT ); Fri, 15 Oct 2021 09:35:18 -0400 X-UUID: 733481741c3b4448b60da58bc95f8d4a-20211015 X-UUID: 733481741c3b4448b60da58bc95f8d4a-20211015 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 25211326; Fri, 15 Oct 2021 21:33:09 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Fri, 15 Oct 2021 21:33:08 +0800 Received: from mtksdccf07 (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 15 Oct 2021 21:33:08 +0800 Message-ID: Subject: Re: [PATCH] scsi: sd: fix crashes in sd_resume_runtime From: Stanley Chu To: Miles Chen , "James E . J . Bottomley" , "Martin K . Petersen" , Matthias Brugger , Bart Van Assche , Martin Kepplinger CC: , , , , Date: Fri, 15 Oct 2021 21:33:08 +0800 In-Reply-To: <20211015074654.19615-1-miles.chen@mediatek.com> References: <20211015074654.19615-1-miles.chen@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Miles, On Fri, 2021-10-15 at 15:46 +0800, Miles Chen wrote: > After merging commit ed4246d37f3b ("scsi: sd: REQUEST SENSE for > BLIST_IGN_MEDIA_CHANGE devices in runtime_resume()"), I hit the > following crash on my device. > > static int sd_resume_runtime(struct device *dev) > { > struct scsi_disk *sdkp = dev_get_drvdata(dev); > struct scsi_device *sdp = sdkp->device; // sdkp == NULL and > crash > > if (sdp->ignore_media_change) { > ... > } > > I checked sd_resume() and found that sdkp is possbile to be NULL, and > there is a null pointer test in sd_resume() for this case. > To fix this crash, follow sd_resume() to test if sdkp is NULL > before dereferencing it. LGTM. Reviewed-by: Stanley Chu