From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f40.google.com (mail-pj2-f40.google.com [74.125.227.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DA0D372EDD for ; Wed, 30 Sep 2026 03:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.168 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790738170; cv=none; b=UE6VjsN4ji3n9FxqQm1OCQJz1vP84BAlYf+FL95lCzwY+WHYIB/0OZp2EG8YfeSNutPZHp8DOPFDG6gTkz8qcxeJJGxq2Pq3ShBhyT1yyYRDvcABmmo5uRi0VwAs0v7h1qQdzPRHC9M/NkkPDPFNaNiG5Sp1/SSR6+hh0+JkRfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790738170; c=relaxed/simple; bh=0DvFLtWh/YNSEWIGblWeCEsGRSgydftqKVETMB0AC28=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hAAkBUFHJkrT20kExFoPzhUFL7D+SsMdE4wvpJ2+RlzUXsPgqrVLSW4K3C+ocVhSJEB87bXzyGHDCBo2sXNz3azIoI3xSEDLLZXhk3FEEnlBrthDGoSkbU9LU0F4lByDNS/w/ZotJhZK6C3D2/UeM/LqGDBEO1t8hmGyx+HJvMQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q3NaAPR5; arc=none smtp.client-ip=74.125.227.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q3NaAPR5" Received: by mail-pj2-f40.google.com with SMTP id 98e67ed59e1d1-3a0eeda3e03so1818262a91.1 for ; Tue, 29 Sep 2026 20:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790738168; x=1791342968; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L9oO5px/tUz63X6zzeE/TZluG5rtkY3Gx9MGMQ40YwY=; b=Q3NaAPR5L3yrx6gadDW56BAR7O7xiVZUQIOnQSmfZfrPqI6SVjVQRnHg6GZ14xfwLQ ep+UIMAbZk/gL4SDdoDC7Dcn1TjFvuDf68PykqhMynzxVgKmfrnFkxcdEPdEBLSpR7jm 2Kvwv9okV3vODZePEN8Xnj7fzwCxVPRnWVD7FTj8LFON48qoPc6HnOF/fT1Di3+xkxTh 5CH2H3Fyfp3aMGyR2w11nQhFusU4+DewxwXb6o9IDI4ruRFMwhsINyjy8OMZ/KAr31nT p33zIGQ3PcIaJe0kTPQ5S8gK+vmJ6456VzlNRlJLCyf2cNynGk3TizAxhkO+Hr8GwWYM 6BMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790738168; x=1791342968; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=L9oO5px/tUz63X6zzeE/TZluG5rtkY3Gx9MGMQ40YwY=; b=PyOciIh9u7w+DazeoYcv5J3LdjEBcO8T1Hzb1h0WIhE6qsQlpaqTWmgoMARjyyecDt KFEIZqPqA+64Cff45hJLxaVL4EoLsZi+CbHvWyMqELzxlyitnPGrojQxhmHQ7tEgv6aN jPqNu8x6kCaCK4pVg6pVBKfdzdL/qUADtvng3hOxz8DvfTVIja0tedm1xpLfXie9CdCf 5oKvljLZBrgXPRsE7Qywo/UO+DKAWCXh8/rb+CFWJJZX4muOfiGUhDFiKqEZ+c/r7a+W YHfriNPE2bgGZOV8kU5uaSvaP0wGA0ayCEwHMIEFKuQjnejoaIHWB+ulQ7/56OqJyg5t gAjA== X-Forwarded-Encrypted: i=1; AKwUvBwgyg+2t5P3tM826hUeWh45kangkQsInkEYB+SkSFiZMcSt1O1tMJFXWL3+U02KHS6ZosL5zrGbjERzXTMg@vger.kernel.org X-Gm-Message-State: AFq9FYJoPT/sxRg36WTnBFaCvi1IVAqPh8aroIu67UbEXWE+L1WYBJJ8 VDJO1PLXYNCq5PuMTyZGJ0JJBlJx+vFhh70m85ij7lLxz7KH+pZPJNcjgyLuYw== X-Gm-Gg: AYBFou1YdBExha3tlsib5bOgWPcoU5bS4upspphiRrBC8q/L8eBUtl38pOm6aYgs8YR IbW8uXaY8gtLLKbJABekL45gKbk5DSOVcrCV2rg0k8INHwbdC0t/wWw7I4OAtmOF9iR/Q/KiN4K iSJTBF9XbcX1LPwnEGR/IneTrrWy17uRNRAZrqL454DMuoQA5kKXShP6Lf2luMJY9tKpYBrsCXu K21ejcqlNmTRDeYFfN00ELBczTtf63EA6Icn6HnQ/97AqJMTntW+u8L3AAT5nG9txFxXIPRl52l +tC63JZtCePSxyItiwQunbMjo5wRk5BhSTeCll4TnRq3+y358jJj8xM9NJSbUxPwte21oxbfis4 94+BHrGNbwNDHfk6glcihSxa3jOodRwpZyWlRnpqS6CL9KosEmo453LQbCJ7f8Pi/0yWMMUgL+a zIsq1Qs++1k1B+IQUnvrEan/OYRRKTFN75gZxyRekNtR/gShdtjnBmyUr6m0q31SUAhmG5WQDdf wfxnIgR4KhpkAXyqWmHVbO8ywUV2ymcqPj90woNYiPg2OW4oc3IXuhtDlc7wOIn4JMkBodWyhKW 4pQEizOut7/OU0ax3o4x X-Received: by 2002:a17:90b:3c8d:b0:3a0:becb:914a with SMTP id 98e67ed59e1d1-3a4d0f038femr58495a91.3.1790738167868; Tue, 29 Sep 2026 20:16:07 -0700 (PDT) Received: from phui-2.c.googlers.com.com (25.187.82.34.bc.googleusercontent.com. [34.82.187.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3a4ce1c9045sm588743a91.12.2026.09.29.20.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 20:16:07 -0700 (PDT) From: Hui Peng To: Anders Larsen Cc: Matthias Goergens , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Hui Peng Subject: [PATCH v4 2/6] qnx6: release bh on error path in qnx6_block_map() Date: Wed, 30 Sep 2026 03:16:00 +0000 Message-ID: <20260930031604.70544-3-benquike@gmail.com> X-Mailer: git-send-email 2.56.0.rc1.315.gc6ed9934b7-goog In-Reply-To: <20260924073920.2782917-1-benquike@gmail.com> References: <20260924073920.2782917-1-benquike@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In qnx6_block_map(), if qnx6_check_blockptr(ptr) returns false while traversing indirect tree levels, the function returns 0 without calling brelse(bh), leaking the allocated buffer head. Call brelse(bh) before returning 0 on qnx6_check_blockptr() failure. Tested in QEMU against tip of mainline commit 62f4c998b297 ("Merge tag 'parisc-for-7.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux") using a loop-device reproducer reading a file whose indirect block contains an invalid block pointer: on the unfixed kernel, check_bh_leaked() detected indirect block 5's buffer_head leaked and pinned in page cache (indirect_page5_leaked=1); whereas with this fix applied, brelse(bh) is called on error and the buffer_head is cleanly evicted (indirect_page5_leaked=0). Fixes: 5d026c724220 ("fs: initial qnx6fs addition") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Hui Peng --- Changes in v4: - Rebased cleanly onto upstream mainline commit 62f4c998b297. - Added QEMU test procedure and verification details in commit message body. fs/qnx6/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c index c999dcfdc477..080f7698a5e0 100644 --- a/fs/qnx6/inode.c +++ b/fs/qnx6/inode.c @@ -144,8 +144,10 @@ static unsigned qnx6_block_map(struct inode *inode, unsigned no) levelptr = (no >> bitdelta) & mask; ptr = ((__fs32 *)bh->b_data)[levelptr]; - if (!qnx6_check_blockptr(ptr)) - return 0; + if (!qnx6_check_blockptr(ptr)) { + brelse(bh); + return 0; + } block = qnx6_get_devblock(s, ptr); brelse(bh); -- 2.55.0.1082.g2b9226bbc0-goog