From patchwork Thu Dec 12 13:38:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13905204 Received: from st43p00im-ztfb10071701.me.com (st43p00im-ztfb10071701.me.com [17.58.63.173]) (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 ED4C62147FD for ; Thu, 12 Dec 2024 13:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.63.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734010781; cv=none; b=R6LXYkwfUN3aIXc4XNHEQSBtrAY+ItIQNf2fHKILArSX/ucabIUxBPAt0g6eH/rl2OtePhxOBpNMzhmUUc8naI3/XKr7xtvyerANcezxDzK9IhCz8CMksoPlcWlWZl+W7eKvtjRbi9AK4hyxd22GE2p29aiOII9bbDSfKAclFXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734010781; c=relaxed/simple; bh=VJjh6ZhXKGcVCCDU2UfjvJvEycscGCyQOOsgxx+2wNQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PtxgUI5G9KBwtetaAy8UuFUI8AnGEINZTjXW9kFX5mFVM0/xcYyndDnDMNZB2JR2vQ3SFp4prxazUBnUKfEGrdYJFEjNtgm6mu1gETOjPBC1NTJHX6eXQTD2QzP4ujLpbb7p6jgExjhsxShLMk4mSZTE5sTkm8gicf4bVCYbrb8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=WE2C1rat; arc=none smtp.client-ip=17.58.63.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="WE2C1rat" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734010779; bh=cpH9bgdtvAV2gtShH3Xs87qkc05FUN80N1S8SieWLOU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=WE2C1ratPFZQR/5lUr/YlEzqb7pn4kCQ0/XkCbMdWg4xciFjIXXwugk5e1nOAbw/u RJyVn2Ys/hw1e9TEgRnOE75GO6bzm+c8YnS3vc+xy4fJ6U4X2p6jGlly5lktdQe14R fKpsVZeqaIGIkMsLKwnUl5Yqp1ZgCsXhs9LIzN+aRQHUSdN3p4ZkWEn6v6NsfXKE5F zbweygnUJoU9qx7d4dB6nU11goc+hG3Ij6dDc1LR1z9+9quGnx2L6olpVQ3gS56L1p 2/3yIDNTq3lJRSj2nAyNPha8rs0mXrFPEoORDg5XLjKFmYsj1zyQQ/HLjORP41aX01 /JOJ6FlPXdBzg== Received: from [192.168.1.26] (st43p00im-dlb-asmtp-mailmevip.me.com [17.42.251.41]) by st43p00im-ztfb10071701.me.com (Postfix) with ESMTPSA id A3680CC01D3; Thu, 12 Dec 2024 13:39:29 +0000 (UTC) From: Zijun Hu Date: Thu, 12 Dec 2024 21:38:38 +0800 Subject: [PATCH v3 2/9] blk-cgroup: Fix class @block_class's subsystem refcount leakage Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241212-class_fix-v3-2-04e20c4f0971@quicinc.com> References: <20241212-class_fix-v3-0-04e20c4f0971@quicinc.com> In-Reply-To: <20241212-class_fix-v3-0-04e20c4f0971@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Tejun Heo , Josef Bacik , Jens Axboe , Boris Burkov , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams Cc: Zijun Hu , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-cxl@vger.kernel.org, Zijun Hu , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Proofpoint-GUID: RBdV7Ki3-LPAth7cquZxpYKME9w9qxmu X-Proofpoint-ORIG-GUID: RBdV7Ki3-LPAth7cquZxpYKME9w9qxmu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-12_09,2024-12-12_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412120098 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu blkcg_fill_root_iostats() iterates over @block_class's devices by class_dev_iter_(init|next)(), but does not end iterating with class_dev_iter_exit(), so causes the class's subsystem refcount leakage. Fix by ending the iterating with class_dev_iter_exit(). Fixes: ef45fe470e1e ("blk-cgroup: show global disk stats in root cgroup io.stat") Cc: Greg Kroah-Hartman Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu Reviewed-by: Michal Koutný --- block/blk-cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index e68c725cf8d975f53703ecf6e6c50594076204c8..fb9858efdfe9443704cb9a239def0e08addf2518 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1138,6 +1138,7 @@ static void blkcg_fill_root_iostats(void) blkg_iostat_set(&blkg->iostat.cur, &tmp); u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags); } + class_dev_iter_exit(&iter); } static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)