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=1796380053; b=kqv3uaqdZy7uFRjoamYVsU60ALKSWaLFXfINLurlPtY4mEwsqHBtFOMWbvGhAP8A2omm XBea0Un338GSrdBYMmsOaNHwX3PP58Nn04EVa0wY19UQ0CyKj1I94t4qOms4QCLtGUosw 42BGIDKl/Ihr/7EA87sniOSL0vkQrvk444laJyGneQYyOctmNP9kIhCrkgBCs2qD+P5zq 3XG3eGvY84nZGXAZlaBqvP+BWbzL2V0fWtiR6Ly0zjclBVLhbyL1vxKPBrA/MtYGzqLmY TS6jK0tMm78Mmz7ldQ1nkUOqJBz6EWlhpXKNRey6Bs1ukKi5Qt36MZ21lIXiD4Qa8qQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380053; 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=WQx3q1Wc4geE2RPuEI2J20BPdCuxOkzhzbNS/7lJBqU=; b=w19lm4pggUZbi0OY9Kxg9mlvBh/cvzLvAzRLK5qIGzCqY7Nglwch6DX5PrhMnB9WGzZq lm5LcJn/36kJBTVdH5taxUYNx3teaCRLD0rSnh/2XQSjfQY6K2sc62H0rS59OrWz/rbKG bXyaXCzFUuXWdAhbLhy+bKbq8ipSbJFBwD/BwCpKjAxmm7uB/o1AM4C14PEuG4LTQFGAM BP7oLFOXij4Oz5HfIgc8aGmryZmqwDOLMAuZhsBDm8dHH+OlqiDHIqcFJtUpwjMW26XvX tq+KcKf0b1bmBpZJMt8OTgZvoizRVtWqJDpT0zV1O+vUiIiUeQRH2ayAgRE+Y0ufjaQ== 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=aHElahqk; 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 0AA70606A322; Fri, 4 Dec 2026 10:27:33 +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=aHElahqk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7661C1F000C2; Fri, 4 Dec 2026 10:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380052; bh=WQx3q1Wc4geE2RPuEI2J20BPdCuxOkzhzbNS/7lJBqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aHElahqkoyT1rm5SP2b5V/hms6nC0uHvSpjkyM2FgxWVKWGEgztAc0SzBYl+a3cI5 5vtTQhHKDkmCWyeLLlLZG5alIiLUOl1TQ+43WnMYK04HmYNKyllLUey8x60qeW9Ikc KtDXJ8DEyDcil89SeN3oxsaZH+M4naF189oFDEv0= 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 7.3 090/742] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Date: Fri, 4 Dec 2026 18:59:14 +0900 Message-ID: <20261204100637.502237192@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 cc4532c7782f1..6474929f86a67 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -961,11 +961,15 @@ static void ch_remove(struct scsi_device *sd) 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); } -- 2.53.0