From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 B06C3376BCE for ; Fri, 30 Jan 2026 17:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794135; cv=none; b=o4LjyitrXLzzieRZlrjBPFT4JvYcWTQ0yTpd2pO3wpyXX59CJ/wRuLqCwByH+nr5y5F5IwPXuE6rVDoFtqsGEO0GJt3nX/XNPwjuDN/kEti++ntPYXCX1q1GHds+IXfPevoMQuA8jk50qugLeiL5SEIlLL/g90qO+x8EiBZZ2B0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794135; c=relaxed/simple; bh=qcVNhXu4lSpQamngIYXm9nol9bWVpQFbB7YtitN/k3A=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d0wn7lY4cuNO5l3urG0wWdLRlhCnwtnYnO6MRfZHkLjO4mGLmZ66V8nMEia8Im8wuk5vrm8FWqW6Qe5L83kIGalQgoGQZewev5ixblMzz4Xz8g7A09fliaSBfGxmbPJEmB8DAdyc2N1lSRvmPWWX3MQjKbkpwIaqGvLpZmNqCY4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.224.107]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4f2jdg71w9zJ46BH; Sat, 31 Jan 2026 01:28:07 +0800 (CST) Received: from dubpeml500005.china.huawei.com (unknown [7.214.145.207]) by mail.maildlp.com (Postfix) with ESMTPS id 2545440570; Sat, 31 Jan 2026 01:28:49 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml500005.china.huawei.com (7.214.145.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 30 Jan 2026 17:28:48 +0000 Date: Fri, 30 Jan 2026 17:28:47 +0000 From: Jonathan Cameron To: Felix Gu CC: Conor Dooley , Joshua Yeong , Conor Dooley , Subject: Re: [PATCH] cache: starfive: fix device node leak in starlink_cache_init() Message-ID: <20260130172847.00005bac@huawei.com> In-Reply-To: <20260131-starlink-v1-1-30985722d51f@gmail.com> References: <20260131-starlink-v1-1-30985722d51f@gmail.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To dubpeml500005.china.huawei.com (7.214.145.207) On Sat, 31 Jan 2026 01:13:45 +0800 Felix Gu wrote: > of_find_matching_node() returns a device_node with refcount incremented. > > Use __free(device_node) attribute to automatically call of_node_put() > when the variable goes out of scope, preventing the refcount leak. > > Fixes: cabff60ca77d ("cache: Add StarFive StarLink cache management") > Signed-off-by: Felix Gu Indeed a leak that should be fixed and doesn't look like there can be any access to np from outside of this function, so the fix is good. Reviewed-by: Jonathan Cameron > --- > drivers/cache/starfive_starlink_cache.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/cache/starfive_starlink_cache.c b/drivers/cache/starfive_starlink_cache.c > index 24c7d078ca22..3a25d2d7c70c 100644 > --- a/drivers/cache/starfive_starlink_cache.c > +++ b/drivers/cache/starfive_starlink_cache.c > @@ -102,11 +102,11 @@ static const struct of_device_id starlink_cache_ids[] = { > > static int __init starlink_cache_init(void) > { > - struct device_node *np; > u32 block_size; > int ret; > > - np = of_find_matching_node(NULL, starlink_cache_ids); > + struct device_node *np __free(device_node) = > + of_find_matching_node(NULL, starlink_cache_ids); > if (!of_device_is_available(np)) > return -ENODEV; > > > --- > base-commit: 33a647c659ffa5bdb94abc345c8c86768ff96215 > change-id: 20260131-starlink-b23bf5ac7323 > > Best regards,