From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52A7D2236F2 for ; Sat, 8 Aug 2026 01:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786153833; cv=none; b=t1UJXcUPNC79lh7bDPNIR/mV3p5ukg78fDOEiwq/YExwn0FLj7bMUwL8yCAT/bRPCrpz4laokOyU0v4aovjEBO+TCi8VuNwUgQHrrXzkCSQa+L8j74X32xMXcYUZYu/g+DgS4BrWW8AkIZ8UmKXP4OW0I+Xru/yHUbYcgmceWWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786153833; c=relaxed/simple; bh=YvSft4pfTWDvuPcdUg3np6MK2uOSIIaFbH/rzyT0KQo=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=c5/UuNQvZiPWhBBneTVOgQB14XGlaJp2NHXgTreCDsIPfY1KZZiE0rXY7bSYH7+ZV2oIXur4UPkXqWEFO12HRS2hRgFb/Ff9Rzx7RybERAhMQ2zDf2PRZnoioRg3JJmuPkRtMcznDasM+CkU9zs1arE5zWx7+tuzNabR0ur1EwU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=ijjjCSWb; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="ijjjCSWb" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=FYEubiyYr6zS1fRSlm+uizseM6hbxeSSR9TZ4jFwLPE=; b=ijjjCSWbHGYQo4l4UiFOlOVbMe57x1p34SCgZlF6yO2U3072qNOL/fOt7RrzN4585vPYsuP/e J6ZGgMB6Pd3jgwc0qwH3GVTxKPCfOcakF0KxblByiYn0bNmmtw3oqhvUMzyMmpChiGJX8fwg1UP pj7cqEJd84SXdUkLRm0gPbs= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hH3cP0cdKzcb0T; Sat, 8 Aug 2026 09:40:21 +0800 (CST) Received: from whupemo200011.china.huawei.com (unknown [7.152.185.179]) by mail.maildlp.com (Postfix) with ESMTPS id 59D884056D; Sat, 8 Aug 2026 09:50:20 +0800 (CST) Received: from [10.174.178.46] (10.174.178.46) by whupemo200011.china.huawei.com (7.152.185.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 8 Aug 2026 09:50:19 +0800 Subject: Re: [PATCH v1] mtd: ubi: Release device reference on busy detach To: Yuho Choi , CC: , , , References: <20260807204550.1016755-1-dbgh9129@gmail.com> From: Zhihao Cheng Message-ID: <27eaa6d4-cae1-2e44-6b46-a753c2475c50@huawei.com> Date: Sat, 8 Aug 2026 09:50:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20260807204550.1016755-1-dbgh9129@gmail.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To whupemo200011.china.huawei.com (7.152.185.179) ÔÚ 2026/8/8 4:45, Yuho Choi дµÀ: > ubi_detach_mtd_dev() obtains a device reference through ubi_get_device() > before checking whether the UBI device is busy. The busy return path drops > ubi->ref_count but leaves the device reference held, so the device object > cannot be released after a later detach. > > Drop the device reference before returning -EBUSY. > > Fixes: 7e84c961b2eb ("mtd: ubi: introduce pre-removal notification for UBI volumes") > Signed-off-by: Yuho Choi > --- > drivers/mtd/ubi/build.c | 1 + > 1 file changed, 1 insertion(+) I think you have sent this patch before? https://lore.kernel.org/linux-mtd/26c9c959-a3b6-e1de-1215-887990a46870@huawei.com/ > > diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c > index 674ad87809df..ee6ce4471b25 100644 > --- a/drivers/mtd/ubi/build.c > +++ b/drivers/mtd/ubi/build.c > @@ -1105,6 +1105,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) > ubi->ref_count -= 1; > if (ubi->ref_count) { > if (!anyway) { > + put_device(&ubi->dev); > spin_unlock(&ubi_devices_lock); > return -EBUSY; > } >