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=1796386183; b=QZu4Niyu9U6O3VKJVh4HBxqndHNYC/eJfIJ1ofz5F1fnx7heACKq6ZGg5HUCUyT94NxZ WwEjXVP64DqPpx+O5cUFf6u5VGdNdg6eX6mTtUYtLKN6LhBD9VEwwk9diLeftBntuIRyb ZowZRP52zSb6rrDZs0XH7VNHj5PeOYYRWqfm4TdufIuiJVssPDEsxM3fcLcur5gGWtLk2 EZki6ngTOGq8UGoyGM2gW8l1bN7uAYdb3eKvItalltk3VrbR5tWtyqYJ2ewn6E9A1wrPD /1G0v6pc3pC48c4On24KSiD8F9Ij/15de6fZZ9AhQwcGXHaXd5/hg4JtxVMVFKDWlIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386183; 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=/Lj1pBe84ZTirk/nEHAGTOzBb6g/f/zxXOE7QU3NwFk=; b=FMKMp69+BrerbwIxMZcR+D3oMJZFNGV1FoANC/wkrEfmQdYmBbc2FaTaNpnv15dFOovL SOk2WJCfZ+NamSFvQnSEEycxXOc8o+Tgh4YPiYlFylnbiFjKMav4iH1DAKgKeGHRN/HOx Kcg6Bn9bXVSYMRXvvPdyjqdVFCa072Xxi7wCBfLpFLkTpBnapM+ZVR3gDBb7xMiT2QL+t Xs6ucio0InF/RCYkuAn9T1j/1AUS+PVqSQo8n9FkT8R/3FG0s6yhWTXhUxs/SL78tgdT5 4N+ds4sP29aHQd/2F8lgeV8Os7TFCBHR4Sv3AiMGaCsD383yxz+9YJBu7sikdd3k/bw== 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="GfUuBE/b"; 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 51926606A32F; Fri, 4 Dec 2026 12:09:43 +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=GfUuBE/b Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE8781F00897; Fri, 4 Dec 2026 12:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386183; bh=/Lj1pBe84ZTirk/nEHAGTOzBb6g/f/zxXOE7QU3NwFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GfUuBE/bimqOHJ1lUIRcyqsAeVB7uDW1FXmtPiQGvDRHXI6oMIOr47cBDiHug5DwY C7+aa2nf0IIGcm14PHs8s3tF6UwTeP+wAjH8uE5MAGWzP6MPh2RDkLn+RdrG9o8EM1 PbbdS4WVnR2c1uLSm+3PYxtRHeaYBvDPyKceM1CU= 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.6 0862/1167] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Date: Fri, 4 Dec 2026 19:04:49 +0900 Message-ID: <20261204100724.568601599@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 c52b2102ca8e6..1cc407b91a0ad 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -953,11 +953,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