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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBAA5CE7A96 for ; Fri, 14 Nov 2025 09:11:29 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4d7BG828MLz2yxl; Fri, 14 Nov 2025 20:11:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1763111488; cv=none; b=CsHXKbia4Bm8r2RNIf2ndBUxLpuMSug5KTMoy6xlGgdVupzGuhhtCLOk7Xp5nUz4XaVSdcm42etACbPnwS0xzcMNbPS98s/mdyrGtoPB3sRsUob0+A/09kIU54vWkCYT5KpGvKFgH24VJTHghAuwgf48RUUH2sy7P3SJa8yX/aBMc+gmu1E5+vWxW72Ghzi+enLwkKptUn/6Eso+XV580hkV6+i8m5pWPcvXuXGcnaV3eyXf11BBqsYGGxt2i1VMSdOfyOR4bT+u1AKMsN8OUS4146xX8Y2gYQPKN4w0WHaV101iFVreC+9z5vs9OjXm1Sl9ioW7A5CEQhnZVUOuHQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1763111488; c=relaxed/relaxed; bh=JJWaEMTs1hq2LaV6TxhfSa7kYchgm/2IrnGqHTnszFc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UuzG76dwSh6kIEEYwFXhiJCXF5ajm7H4PNCtq/bP2GEBB5scfXUw5ndzwa3NVA+TQr9Tq7xOBNIQc6RvExdXMykWQiWg2WXP375nH9uJq+46Tg5lLXUQQUsqR0Xc+jCwYQOghumbyMVBSMCY2Z/eD5ylImtllv4bDFDGgygpBkg2bknOyRGXVKkTfsEatrCFCnxVJaFsHQ3cYo80lrhrSN6lir0XYZYsm2vQDuOkj5YlvaVfuToVkDD893LkzirG+/vI3DzIRkO0oGWOMBVDHZDCzL9BN/MK/MFbCwBVLi6jElrY3B3gXDGxcN2hBmjltQ5JO3aypkvH+y9/ZzuLFA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=qDL/ZFoo; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=chleroy@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=qDL/ZFoo; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=chleroy@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4d7BG72X2Sz2yx8 for ; Fri, 14 Nov 2025 20:11:27 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 720B242A16; Fri, 14 Nov 2025 09:11:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12C26C4CEF1; Fri, 14 Nov 2025 09:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763111484; bh=4bUe5Ax7eP5+O7eH4xwn1ucE348NJIHO1n8FTISL6Wk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=qDL/ZFooJb8prJ+A5aXqzeCEsCIeVSCJ9HXcKqM+XON3p75vVtCyUZy7lWYQ4eCz/ +z2JSFQAbWBZulQ/jzOAHjxpO9klt8A0ULEOth50qNtoqOojUbiL5be1zN6TglfKyA o9CZIydGR3Ks496J7GqPO58FeUFwpSylZ0Z4PuO/HOV5l5B7OQ4flhLoOzU2jcqVuf NfSKk/mFCSCOl0GbibxdkCZmJD4N4UtW+pfbDzftDFoHcp2Kqdw/KlBmYni2Zw/ZOM FW4Gd9xAoiPLClhPBig3kExl8BZM8d0AD0j85bksdu43agdSm4XeRPmiit/m2klW7E GhaWeyOsr+H6A== Message-ID: Date: Fri, 14 Nov 2025 10:11:17 +0100 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] powerpc/powermac: Fix reference count leak in i2c probe functions To: Miaoqian Lin , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Thomas Gleixner , Ingo Molnar , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org References: <20251027084556.80287-1-linmq006@gmail.com> From: Christophe Leroy Content-Language: fr-FR In-Reply-To: <20251027084556.80287-1-linmq006@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 27/10/2025 à 09:45, Miaoqian Lin a écrit : > [Vous ne recevez pas souvent de courriers de linmq006@gmail.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > The of_find_node_by_name() function returns a device tree node with its > reference count incremented. The caller is responsible for calling > of_node_put() to release this reference when done. > > Fixes: 730745a5c450 ("[PATCH] 1/5 powerpc: Rework PowerMac i2c part 1") > Cc: stable@vger.kernel.org > Signed-off-by: Miaoqian Lin > --- > arch/powerpc/platforms/powermac/low_i2c.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c > index 02474e27df9b..f04dbb93bbfa 100644 > --- a/arch/powerpc/platforms/powermac/low_i2c.c > +++ b/arch/powerpc/platforms/powermac/low_i2c.c > @@ -802,8 +802,10 @@ static void __init pmu_i2c_probe(void) > for (channel = 1; channel <= 2; channel++) { > sz = sizeof(struct pmac_i2c_bus) + sizeof(struct adb_request); > bus = kzalloc(sz, GFP_KERNEL); > - if (bus == NULL) > + if (bus == NULL) { > + of_node_put(busnode); We are in a loop, what happens when kzalloc() succeded in the first iteration but not in a further iteration ? In that case we have already registered some bus which references busnode as bus->busnode so it just can't but put. > return; > + } > > bus->controller = busnode; > bus->busnode = busnode; > @@ -928,6 +930,7 @@ static void __init smu_i2c_probe(void) > bus = kzalloc(sz, GFP_KERNEL); > if (bus == NULL) { > of_node_put(busnode); > + of_node_put(controller); > return; > } > > -- > 2.39.5 (Apple Git-154) > -- pw-bot: cr