From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383300; b=EmMkZvK5Dhp8iknzx/WuDhllHcvmljFFUaRtZQomtlF5BObfMMi/s/XENrgDNCyUeAaX J6P8sxnKE6i5kcLA2/PwHhZ8DBwAeIAqvpsuRsk+3SHg86XjLClIPuN4/uCuAdX+JWYSV IZQvrzFGT/Rx932HWCOYcLVIaQHZXtSPfP8SOTr2lJOYaGLlS7T68Xv7E1B9cA/iTS+Fz 5LmfAZjubks92GCMuMrmj92KPTwKsrvOA3uHeaQ7+lw7AEpvQAiWkyaJsSQcxrp33USMq SCQrcFqV5ONI1CAl+yk0JOf/r8DaG55AYxe98e6KMKxaq2qdHvahAcul0vE66fi5PUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383300; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Cw5UeAidN3JjBQm34bGtx+O7uev56a/c810Ubwqlscg=; b=z/MT7hnlXh/Vu7wqoUD+y86QUYoAbWaTpa3HcNab08alVuD7pK56ouBbI2FnHQrTjWdT fk1RdH9xEboeGSc0OniSaoNAujv3xdA0yKCXxFz6cA44ZbetMdibqCic1NkJm/CcTxDFJ wlBSmCIT3YkGyzy5FQANmDjyDzBu97XLQjbxxtbJ9tPK6KA4mIP4Xu+8090Pz3wqhZ1G5 dEDuj4RxyP0bUFYsFBSE6xadcrafC8uE0f+dlwGRSvqx5Jv7rfokO/Rh3caWMflde09YD g0gWwLu22EZmC97E06mz0tnue6WUNILEdAgiE69c8/s2DtRcvEAIwmChN94T+nRw/qQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1b0DhbzU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38D18606A332; Fri, 4 Dec 2026 11:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1b0DhbzU Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8FEC1F000CE; Fri, 4 Dec 2026 11:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383300; bh=Cw5UeAidN3JjBQm34bGtx+O7uev56a/c810Ubwqlscg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1b0DhbzU9L+pWewv+GOV8uUP6+f0x63G+zrUs14KN1oDr6CorS33WGBaYOs8iDnnd ryw7OQl3OF+tnTY80Y/3xJlpI/HqSV5L/bU1x9vDfO5e9FZfZ3QElVFomwcURmffZQ 6zfRasyjJRWbQg1Yvajqz1JAxo92E02bsyKktzno= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Changyul Lee , Laurence Oberman , "Martin K. Petersen (Oracle)" , Sasha Levin Subject: [PATCH 6.12 166/555] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Date: Fri, 4 Dec 2026 19:03:29 +0900 Message-ID: <20261204100614.543194766@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Changyul Lee [ Upstream commit 9f9e0b1e5399045982788a954d3461de894e40c7 ] ch_remove() removes the minor from ch_index_idr before device_destroy() removes the "sch" device. A changer probed in between can get the same minor, and its device_create() fails: sysfs: cannot create duplicate filename '/class/scsi_changer/sch0' ... ch 1:0:0:0: ch0: device_create failed The new changer is then not attached. Replace the IDR entry with NULL instead, so that ch_open() still fails with -ENXIO for the changer being removed, and remove the minor after device_destroy(). Fixes: da707c54c342 ("[SCSI] ch: fix device minor number management bug") Signed-off-by: Changyul Lee Reviewed-by: Laurence Oberman Link: https://patch.msgid.link/20261109160651.986356-1-lcy8047@gmail.com Signed-off-by: Martin K. Petersen (Oracle) Signed-off-by: Sasha Levin --- drivers/scsi/ch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 95bbcc497de9c..711d02353ae7b 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -960,11 +960,15 @@ static int ch_remove(struct device *dev) scsi_changer *ch = dev_get_drvdata(dev); spin_lock(&ch_index_lock); - idr_remove(&ch_index_idr, ch->minor); + idr_replace(&ch_index_idr, NULL, ch->minor); dev_set_drvdata(dev, NULL); spin_unlock(&ch_index_lock); device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor)); + + spin_lock(&ch_index_lock); + idr_remove(&ch_index_idr, ch->minor); + spin_unlock(&ch_index_lock); scsi_device_put(ch->device); kref_put(&ch->ref, ch_destroy); return 0; -- 2.53.0