From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 481933DB31A; Sat, 12 Sep 2026 12:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789217842; cv=none; b=D/Wbru0JDPV0EcQpbPaxjBlKfATm6QVIJCl9kC6b/FN/ulieYVzHaV4OUnNmt1cIt5E4PaOYvr9iMGz7doRIluE/SlPXKiUm6SB370vf+Kag45oSmY9v50qgFVG/xzHi+C0bg2+SPPJ8umnLbn6YFXxzr17ANA7ajKsr4n3qmiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789217842; c=relaxed/simple; bh=719UDM/KmeMHft+5oha71SdoH6P22HxLnekYQuKzbNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pX/gmTXzrnkVIm+ZdhM5cMfczuVqtCOtu/LDVIkYMFNXqkYJAXRxIKJYC/g6aH63rb1MnmMeaEZxYTwfU9C7UQG8vP6bjNe8jhoteggorR2yglmGoDp3qOcxtpHsU3tu5Jcw+7HdgGEh3u/t4N9CumRw7kYkMTh6v/lI3yjHeHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1uRINHM1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1uRINHM1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EA4A1F000FF; Sat, 12 Sep 2026 12:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789217841; bh=LhuSk6ItFCqKZ+8AHGOKwh4+7ZwOLT4PsEXp/jyr3ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1uRINHM1NqK5Y8xRwmaNZU0CMp1wVU07Jfa6wDLJuE/lr+Ps5OtS+N9L7EM4xfILn 7ENigwcHdpcbfOcTKYZEi/IDL8PmDaCjccnea/+6ZvHR8q+nXaUxsaIeRkEBSOBy9E 54pRliHb10D0qQOYJTYyaYCIQuysoTI8WwabKRIA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Himanshu Madhani , Johannes Thumshirn , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.12 0979/1376] scsi: sd: Move the sd_remove() function definition Date: Sat, 12 Sep 2026 08:56:45 +0200 Message-ID: <20260912065629.387290469@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche [ Upstream commit 4f39a4870a59971797be86fed72423b83b6b4e00 ] Move the sd_remove() function definition such that the sd_shutdown() forward declaration can be removed. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Reviewed-by: Johannes Thumshirn Signed-off-by: Bart Van Assche Link: https://patch.msgid.link/20260114175054.4118163-2-bvanassche@acm.org Signed-off-by: Martin K. Petersen Stable-dep-of: bb31844d88b7 ("scsi: sd: Fix special_vec mempool leak when scsi_alloc_sgtables() fails") Signed-off-by: Sasha Levin --- drivers/scsi/sd.c | 53 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 7c15f36c218c3..01e8d71c02547 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -108,7 +108,6 @@ static void sd_config_write_same(struct scsi_disk *sdkp, struct queue_limits *lim); static int sd_revalidate_disk(struct gendisk *); static void sd_unlock_native_capacity(struct gendisk *disk); -static void sd_shutdown(struct scsi_device *); static void scsi_disk_release(struct device *cdev); static DEFINE_IDA(sd_index_ida); @@ -4050,32 +4049,6 @@ static int sd_probe(struct scsi_device *sdp) return error; } -/** - * sd_remove - called whenever a scsi disk (previously recognized by - * sd_probe) is detached from the system. It is called (potentially - * multiple times) during sd module unload. - * @sdp: pointer to device object - * - * Note: this function is invoked from the scsi mid-level. - * This function potentially frees up a device name (e.g. /dev/sdc) - * that could be re-used by a subsequent sd_probe(). - * This function is not called when the built-in sd driver is "exit-ed". - **/ -static void sd_remove(struct scsi_device *sdp) -{ - struct device *dev = &sdp->sdev_gendev; - struct scsi_disk *sdkp = dev_get_drvdata(dev); - - scsi_autopm_get_device(sdkp->device); - - device_del(&sdkp->disk_dev); - del_gendisk(sdkp->disk); - if (!sdkp->suspended) - sd_shutdown(sdp); - - put_disk(sdkp->disk); -} - static void scsi_disk_release(struct device *dev) { struct scsi_disk *sdkp = to_scsi_disk(dev); @@ -4187,6 +4160,32 @@ static void sd_shutdown(struct scsi_device *sdp) } } +/** + * sd_remove - called whenever a scsi disk (previously recognized by + * sd_probe) is detached from the system. It is called (potentially + * multiple times) during sd module unload. + * @sdp: pointer to device object + * + * Note: this function is invoked from the scsi mid-level. + * This function potentially frees up a device name (e.g. /dev/sdc) + * that could be re-used by a subsequent sd_probe(). + * This function is not called when the built-in sd driver is "exit-ed". + **/ +static void sd_remove(struct scsi_device *sdp) +{ + struct device *dev = &sdp->sdev_gendev; + struct scsi_disk *sdkp = dev_get_drvdata(dev); + + scsi_autopm_get_device(sdkp->device); + + device_del(&sdkp->disk_dev); + del_gendisk(sdkp->disk); + if (!sdkp->suspended) + sd_shutdown(sdp); + + put_disk(sdkp->disk); +} + static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime) { return (sdev->manage_system_start_stop && !runtime) || -- 2.53.0