From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0F25CE79D5 for ; Wed, 20 Sep 2023 12:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235039AbjITMAK (ORCPT ); Wed, 20 Sep 2023 08:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbjITL7x (ORCPT ); Wed, 20 Sep 2023 07:59:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE5FF92 for ; Wed, 20 Sep 2023 04:59:47 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25FA8C433C8; Wed, 20 Sep 2023 11:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695211187; bh=kZj1Sg0Q/OWi46q1q3Y+s4iuzRKw4K5EPqHOMnF/C04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQV+MtOUAKM3JwmrqkFTmQOuMUyiAZwcayualKVyzvJjld4yNxmuCD4I5mynuJ5YR ntCXwgQWX5CYxStP9985Ek3EjrTgV6/9jRzzHQhH8iw23UMIbASOtSIO35tQCCfVJj YbSE0zzoH1Fx4W7bdZ/VHbxArOs2ycDRNr8iTAOc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, AceLan Kao , Yu Kuai , Mariusz Tkaczyk , Song Liu Subject: [PATCH 6.1 115/139] md: Put the right device in md_seq_next Date: Wed, 20 Sep 2023 13:30:49 +0200 Message-ID: <20230920112839.849618169@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112835.549467415@linuxfoundation.org> References: <20230920112835.549467415@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mariusz Tkaczyk commit c8870379a21fbd9ad14ca36204ccfbe9d25def43 upstream. If there are multiple arrays in system and one mddevice is marked with MD_DELETED and md_seq_next() is called in the middle of removal then it _get()s proper device but it may _put() deleted one. As a result, active counter may never be zeroed for mddevice and it cannot be removed. Put the device which has been _get with previous md_seq_next() call. Cc: stable@vger.kernel.org Fixes: 12a6caf27324 ("md: only delete entries from all_mddevs when the disk is freed") Reported-by: AceLan Kao Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217798 Cc: Yu Kuai Signed-off-by: Mariusz Tkaczyk Signed-off-by: Song Liu Link: https://lore.kernel.org/r/20230914152416.10819-1-mariusz.tkaczyk@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8228,7 +8228,7 @@ static void *md_seq_next(struct seq_file spin_unlock(&all_mddevs_lock); if (to_put) - mddev_put(mddev); + mddev_put(to_put); return next_mddev; }