From patchwork Tue Dec 24 13:37:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13920121 Received: from pv50p00im-zteg10021401.me.com (pv50p00im-zteg10021401.me.com [17.58.6.47]) (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 6956D1C1F0F for ; Tue, 24 Dec 2024 13:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735047500; cv=none; b=eBJ0KEWvey7gywAeUbVALHMVl7tP9Dr+6/3OZ03R2+jiCyPbneTgBJGKo0+F54TX+oUbdHeMFOZRAn6H8n6LW5nhTk09bUhzjaVx5YfdNsTWRKu4aSMLXIEEczDPGM9RROCnI3GMqC1N0d+KRGbR1SyGtbXq0icC5lP+05ilvak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735047500; c=relaxed/simple; bh=zMjsz7jAuZ/kQmW7w3lfAwa1gsUcolqTbT99cffmGys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pHGoPW+TQvSD7K/282EQ9cGoxnq0kyf5iIOQHXjhQlyP9FPePmzoPp6Qp+RtmDHbj4inQGGFWjvtpNwZAvvK4V2TsurOsuouL5yqt9259A3/cO01KWF2xCu6LC46/TxwUyq3WaCctPdApi4chevDTYpxESm6KPxVl9fik/vE+ss= 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=DTkI+qi7; arc=none smtp.client-ip=17.58.6.47 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="DTkI+qi7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1735047499; bh=kn+rsGruQx2pm0qQwtoirYg6DzCwThWomNn9G8Daxpo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=DTkI+qi7m2SjRclnlZnr7hKk4vcWZea5PVDWLSEuupRbO27Qy89815Spjsp+z6rWT Ss/KchKoJI9c7/BHIRXQc1e+UbrhSYC1534oyTBTDVGNPhiB6EC2nRS8uA38jJCIAu lZxYjybPgnIuG97mau33SDm9ObDWcLJBbsmir16dHaXE0FT/CC1Kj+WHrnHp9qId2O OYmrtcrLasZdFrcBWC4tbRODa/bEiGJhjmp2mpGVjeU3z/LFO9RpF/sVNO0ph7OAdA 9UgfumRWwXEHgJY2A9a+P39ZOvG5YrcPAO+P3ZawUF/sWyjj2eaOey+nRXM4YQgFnb +7LU0XcY5Kxxw== Received: from [192.168.1.25] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10021401.me.com (Postfix) with ESMTPSA id 240558E04AD; Tue, 24 Dec 2024 13:38:09 +0000 (UTC) From: Zijun Hu Date: Tue, 24 Dec 2024 21:37:21 +0800 Subject: [PATCH v5 2/8] 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: <20241224-class_fix-v5-2-9eaaf7abe843@quicinc.com> References: <20241224-class_fix-v5-0-9eaaf7abe843@quicinc.com> In-Reply-To: <20241224-class_fix-v5-0-9eaaf7abe843@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 , =?utf-8?q?M?= =?utf-8?q?ichal_Koutn=C3=BD?= , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Proofpoint-GUID: nSnhKvYpzhjTcrD7NiJ5ZdG4NMq4wFeM X-Proofpoint-ORIG-GUID: nSnhKvYpzhjTcrD7NiJ5ZdG4NMq4wFeM 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-24_05,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412240118 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") Reviewed-by: Michal Koutný Cc: Greg Kroah-Hartman Cc: stable@vger.kernel.org Acked-by: Tejun Heo Signed-off-by: Zijun Hu --- 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)