From nobody Sun Jun 14 01:37:43 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 EC8CB3CFF56 for ; Fri, 1 May 2026 20:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777667444; cv=none; b=prKifYQSqpkVUSgAy2aWzf22MqSwZfBiR6+n7IIKSQvkVqZl5/feVahBomOKkLOo8kDEDN8L+j/0KMd1ffU5seAVbAwJ+lpU1SuIs4GOl6yfFYT+gZUckdRbKtEigBOkWpOlRiTAjmk9BmFzYlDWMlbMS48usJ2ErUnyd4zIegc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777667444; c=relaxed/simple; bh=v5qF9oUjFKKNNHiaZ/cDzrCvSYhthuRxEl4ePROAuGI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=etSHOdF3E7KTaR2+5Jx3aUBylv65ptgR0m7kQ5QSegZIfcvcxQN31RGOhF+PAe2Wgv1jf3eMA/jLeDE/yGP5Qo2hFBIZnG+3SxjiqTl6hZXEjBkQkRh0syeuMg26Wzj5FATNMNFD4WVnJYheyOns+FWtW1UwWZ2+UPqxm6sFvAc= 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=FGO+jCXH; arc=none smtp.client-ip=209.85.210.180 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="FGO+jCXH" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-824c9da9928so1077904b3a.3 for ; Fri, 01 May 2026 13:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777667442; x=1778272242; 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; bh=qVBnu6Q/tQcYvEy05j8zTeFYSonQvouDAQt7Xng1rGU=; b=FGO+jCXHSKDpIfZTzi+KqeQj1n2RE+xbiek+qNmJE4PdwTd714zf5EQvYG57oIi6Oi tZ9UxnPr/9Xbpud32rn/Z1BnaaZ/sKZELwdT2oRc/N8Ha/vE28DQfIsPHwy4xqyOguWT L3l7oGbbQukeSzast7sN4t8wVpyQrESwJStsqRuHp6NTwdZ+mXvFNE/SroyTjrI9QPjD y5NzCZAikmvok/G26FdM8VeGryxnBvexH065x/hW399eHtojC+sON90MlK5c4SmeOggK slhFI51+7FhLP68Yhn/L5Q+/YbC0OKAYGLLdmOt2T5TwR51z5Jtqu4MKAAf6/a34N2vS n6eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777667442; x=1778272242; 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; bh=qVBnu6Q/tQcYvEy05j8zTeFYSonQvouDAQt7Xng1rGU=; b=ifH7xH9zX7HrHtOUQTMVj0BAvqYFs1hWnpJpZ5/OnbbFa8gQ5SEZmCVl69vsiLEEOR PUAXoEBY+RIFme25HT0xRO6/EGm/Y7rdivckhOlfpyr/UiK67aiyGOkJt/CDxu43SIja 8zWzho15ZjmdlliHRWgcf7eC7+eje9SP/0iCNqbUWi2CpGnmyyhJarzSRGII3KtiuL6m q9s3WS84EUtOIUfNgwN1L9LONelHIQiVy//jCSr+AKpfw8nzAVQsyy3D4YpsiytkvjWT NNLHTfNGPdw8i6Z+Y3hqUUFgLi5ADjHMh3m1GU0kJkbCGLLeOq08DDJ86gfS6jx9EBRw 6BZg== X-Forwarded-Encrypted: i=1; AFNElJ8wCrybvACRyh2I/7sI+bkpQO2xnDXsJ1BhGpeK4eL59u5h1cCBwpn39X4D5w9f2JV6hY6ma2Cms56H4kI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxud+cNRbmMfrNpAa/sLIUkiV2t2A3LRPzDO+9hOXmnAeOFvVXe 7GTU3YHILdeGwA7+slkcEfuD0F6CXGF303WIO0CAgNuZLxP27+4eTGO4 X-Gm-Gg: AeBDietOg420b6nu1Wt5sUtuv9+Tp+Yo/Qt0HX7VaMQEyztxxXybr15VfWJkct5wqMl pKnnpkF4IaLYXwiatqNpls5Bb4knzEpHT+GcJ4nw5b6d4pORyi8EqjwVLY/E8UYqo4L0ZxN6F+J 4j7cJ/7Zyj+zZWMfyMgf3sjcbeVppNm51lJ8aEg1kvFzKba3Bbe0jWjG0gepfKrUY/USJRyRRg3 69bIdTWp2yb794Nfx0CD9CopXxhuN6mr9TJE6eFOpkuqBls4KK0nBWz/mci/W11jS1GEJvuR0lZ 5t3gHXCWzBOJeHvjnKhTA3PH67NMffvKysejLwkzO0i9Wozd6oGihGSnWfFrgT89XKd2eOQq9Kh PeVf5qz2+3yw5z3q5sHlpoDZjX6IMnSzPclbs2cfRPbQms8kPp7AlY2gZSOv7lkXGHrgBuqFbyz o0wM5rWiOB2HyBDXMuaWeXvj1H1DMx9L46UqGGjyaGw6LLP5QRHrrB51Zd4ZODVs/tDiA7vtbq X-Received: by 2002:a05:6a00:330b:b0:827:4343:4c1 with SMTP id d2e1a72fcca58-8352d20b2a9mr661002b3a.29.1777667442262; Fri, 01 May 2026 13:30:42 -0700 (PDT) Received: from localhost.localdomain ([115.110.225.242]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515b84aedsm3230595b3a.57.2026.05.01.13.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 13:30:41 -0700 (PDT) From: Shitalkumar Gandhi X-Google-Original-From: Shitalkumar Gandhi To: Andi Shyti Cc: Wolfram Sang , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Felix Gu , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Shitalkumar Gandhi Subject: [PATCH v2] i2c: sun6i-p2wi: fix of_node reference leak in probe Date: Sat, 2 May 2026 02:00:02 +0530 Message-Id: <20260501203002.3382428-1-shitalkumar.gandhi@cambiumnetworks.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260201-p2wi-v1-1-e0ec9cda82b3@gmail.com> References: <20260201-p2wi-v1-1-e0ec9cda82b3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" of_get_next_available_child() returns a device_node pointer with an incremented reference count. The reference taken in p2wi_probe() for the optional child node was dropped on neither the early return when the "reg" property is missing/invalid nor on the success path, so a reference is leaked once on every successful probe and twice on every failed one. Use the scoped __free(device_node) cleanup helper at the point of acquisition so the reference is dropped automatically on every exit path. Suggested-by: Felix Gu Link: https://lore.kernel.org/linux-i2c/20260201-p2wi-v1-1-e0ec9cda82b3@gma= il.com/ Fixes: 3e833490fae5 ("i2c: sunxi: add P2WI (Push/Pull 2 Wire Interface) con= troller support") Signed-off-by: Shitalkumar Gandhi --- Changes since v1 (Felix Gu, https://lore.kernel.org/linux-i2c/20260201-p2wi= -v1-1-e0ec9cda82b3@gmail.com/): - Reword the commit message to make explicit that the leak is of an of_node *reference*, not of an allocation. - checkpatch --strict --codespell: clean. - Build-tested: x86_64 allmodconfig (CONFIG_I2C_SUN6I_P2WI=3Dm via COMPILE_TEST) and arm sunxi_defconfig. No new warnings. - Runtime test: not performed; no Allwinner A31 hardware available. drivers/i2c/busses/i2c-sun6i-p2wi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-s= un6i-p2wi.c index fb5280b8cf7f..652b37b57159 100644 --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c @@ -184,7 +184,6 @@ static int p2wi_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct device_node *np =3D dev->of_node; - struct device_node *childnp; unsigned long parent_clk_freq; u32 clk_freq =3D I2C_MAX_STANDARD_MODE_FREQ; struct p2wi *p2wi; @@ -223,7 +222,8 @@ static int p2wi_probe(struct platform_device *pdev) * In this case the target_addr is set to -1 and won't be checked when * launching a P2WI transfer. */ - childnp =3D of_get_next_available_child(np, NULL); + struct device_node *childnp __free(device_node) =3D + of_get_next_available_child(np, NULL); if (childnp) { ret =3D of_property_read_u32(childnp, "reg", &target_addr); if (ret) { --=20 2.25.1