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=1796381819; b=pXyQtSVJuvqpDMh4lQ6xjbX7dvccm+Ml/M2zgg+a/d1RDeBt8hYYj8NL2QE8PXb2RCoz UgwoTPAsZoZtBoUu/gsTXbsWtLmOldlf6K35dbAvaYGTJl15dI3PXjlmMVLoTEwMW12mT SD7a484cdzVrCwZZNHjV9Lv5/Xr1Gao4lnEBQ7FDHDDLFOqmOJ4VmtjePFeazBjGUnBXv 40cgc2SQmCoLGnimwrhzWWAFA+MXbD/K/lNPUpVQXmrsM16nfM6Vh+4M8hmiRuns8DtWq HmRsOl/p7QJvoRSKlY9/+U9bmxqhTHLuEjq2lvHGcUFf+Du+OU53MSyVJFIxWoh5xzA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381819; 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=YQxfgovk4/c9qWrLTKq15lHBYApodsnsCvN5gZEHfe8=; b=QJXOVB0/YNJv2GVdzCevte+R53N4/oC1knuCIKxbjP5yxWDepv854r4gg7ytg/MvpJhu adCy9R33qa0LF2OoRXJ6YUwHAWiPaun1tEso0RS2n+ojk67wrKdqPNBPx+1FhLzeWjEC8 jVCkwf3r5OKCO7oeMxmoHllZ++C48nZMlaCiNde+m9G4PU24Z31tklWN2je2OiYIxNJZu Kg4B0i+oaCDn0nqGf2VkUOYlmzpCpydDyCBHckwy+FIz0IfcBd+OzUpg/gMHnCf8KMICd LLjs+D1R0ZDqmBaf2AquoWE4koCKRnTZ4hE73NAqBrWUxCZt7bUTjaGWtK83YK9hEkA== 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=d2UWg+WO; 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 4ADF7606A322; Fri, 4 Dec 2026 10:56:59 +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=d2UWg+WO Received: by smtp.kernel.org (Postfix) with ESMTPSA id B07621F00931; Fri, 4 Dec 2026 10:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381819; bh=YQxfgovk4/c9qWrLTKq15lHBYApodsnsCvN5gZEHfe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d2UWg+WOG8KRHYJJhR8sDonxDO01v2nGwLllaCRj9jlEN7dQ8AJ1WDhkOmxovMb7Q n1d1NwMyxwuhnReBE4DlIgqMt4EylKmvXcR6DJWrrvZKuidCrMcKpCS7L1AbrSxSZ2 ZqsZoNDu12OGUZ7OXtvD00RiQqew6P1PJXZpUMSY= 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.18 146/703] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Date: Fri, 4 Dec 2026 19:00:45 +0900 Message-ID: <20261204100631.776772747@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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