Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp217667lqb; Tue, 4 Jun 2024 09:16:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/8TWVV7GgiUQkWHVsSngmtlmfzKfj5cLQXYNLguNsQcqX4uDD6waK6CHm/j1yjCHLY4E7J3T7YxW7+bIwV4SoCI/jGdif8Ex9s0VF6g== X-Google-Smtp-Source: AGHT+IH9ZPz9w0S+aJHhr24Edb5f/KQU+LJ3QBVDWQ89O0enVPgiDXZsZZzpka5BTNul6u8R3sRw X-Received: by 2002:a17:906:5647:b0:a63:3c57:5806 with SMTP id a640c23a62f3a-a699fccb79dmr380866b.32.1717517808915; Tue, 04 Jun 2024 09:16:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717517808; cv=pass; d=google.com; s=arc-20160816; b=gSEyGKF4mNJZ2KrDdm3w+uZlzUGQdZGMqwA12XLIxxP+4Ub4oiNo0DhSU8w+SofiNT UuVHt8OLwG6QiGFGcf8ZzjbMMfcDU/7M5rLoy5v+M7fo324dsz9v+x9mHmwfjARyJiOl h09uXaxK+KnZVtB+u8Qm/XdAQNB6t+xH3GGHPf7nkBPuEt/cLYU1ApncZs9ucRNti7O3 zsvEoSSr2OH5LdM48qeUo5w/CWuCiDgDTXiDx34qcPalIXR1+Vezr2sgp/PN4e0yglnH vmbmy4Cs5UFT3TjpGDKEo1OAk1HcnVT4ip5ctYJFVxTjIxYzaStHYJDUwLo7DgpV6gf0 5WYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=e3+LR+ZFVmht/Z8cxFyxnUYxF5M/8yzA7dtT9UQEbhk=; fh=HYzBewl66dCYl5pRwkuB1hzyOWqqrAff72FpCqAMr1M=; b=OVvWvBi1geNJ+3UTtNIfyqZ3dpA8oplDhs+ThQAVsf1VnZk+UJdoaVSNZkjwhpD6tL GC+mgYdJeRb9zhua6R9VY4atlDAvEWwyH/KIA6athLkhlCNXeAMfpRQ8KTFWjlEk3KIY xDIsuyeACo9aLkJWtHIIx6RMw/xsxDlp2uW1J+FkhHXo8lY+i4OzbnMHOyQivDpUsic1 LGzc5UjM2tuZfBe0geGV5MniwwmGBoGD4rrWgZvDzWmB7LoH+HT4F+CPr4eJMGBdGS3g 53PuXo4qmgdPUyFLs1r019y14oxX7fMnPx9+W868pEGYiEwjvuS5sU5qFuDfMwbckjUl K3dA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hRse4xFr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-201051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a68e2e24614si293585066b.807.2024.06.04.09.16.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 09:16:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hRse4xFr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-201051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A15C11F23D60 for ; Tue, 4 Jun 2024 16:16:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC15E1487C6; Tue, 4 Jun 2024 16:16:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hRse4xFr" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 9399913D635; Tue, 4 Jun 2024 16:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717517781; cv=none; b=kn5Pdw+XilYtcnAZ8dWzujIEIhI+4WQ4WKj7kGu+w/zx6bzyEUyqH3ciieQkE4D3NPMEIV28l6uiNb7fBgTrk4e19agsRjCJvIowu8nCfp6aWAIk7itZVK5zDIs+GhOQGM4gS2TzV+Pa0wrf/d9JZWPIDMJEh6rjXkaTzgGoWp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717517781; c=relaxed/simple; bh=XYwRliGG6vqwmqRscOEguPLD97v+obXl0lmknTVhOmU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nCoxELoJZscVBwgiQt79YRiwcQvzVsCl0PGIlXRgWj13k17SrFjKwIfs75TGKHE1tx9t5gJqaUSq8k5JCGdgNSHBgA1Mx5lsI136GzuifH1UheuBE4Z7O3PIPkkXHHVssA/+xCTUsYz4HPNaEWgD5BivSqUvoR5291rFTEYczmI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hRse4xFr; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717517780; x=1749053780; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=XYwRliGG6vqwmqRscOEguPLD97v+obXl0lmknTVhOmU=; b=hRse4xFrx9hvlmVeY5JYqBRgh4uN+o1N7FjbAVqUhrFNtfp9BNxVdTdl RQcDhRTW0XdzmvP4JnJVBaKEJCJETDrE/C3McC5b/aP+I0oB3J5y5XuhN UY7cHsCr5UJckSAphbS6VIiljCDCZL9R4k4HAgm+j7Wgmhbs9Ypox6Vd1 KcA8LvtTs3VVP5schKjkKzfPDC39YlRUGPpsp4mvfpxQSqFj/5o111qEF sFhqxW0mvJEzzSqVdrYoa6XQJh1JhFW4jDqW2eKZzMkYnKakh7vUXQYya P7c/aWyM7PkxVqfXz0+nEHJNd+d5aP3JEH4o3wov/GzhLXF0+Qc5aGjtb g==; X-CSE-ConnectionGUID: 6CNgZH53Qs2WUhPoyTLBGg== X-CSE-MsgGUID: b1/wSVvBQGuWWjuoQ5h7rQ== X-IronPort-AV: E=McAfee;i="6600,9927,11093"; a="13919490" X-IronPort-AV: E=Sophos;i="6.08,214,1712646000"; d="scan'208";a="13919490" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2024 09:16:03 -0700 X-CSE-ConnectionGUID: 7fkVkoAPR1a+blKuqpTKQA== X-CSE-MsgGUID: YOlWfs+USnOPzP+FZEWsSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,214,1712646000"; d="scan'208";a="42400135" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 04 Jun 2024 09:15:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1948A2DC; Tue, 04 Jun 2024 19:15:57 +0300 (EEST) From: Andy Shevchenko To: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [PATCH net v1 1/1] net dsa: qca8k: fix usages of device_get_named_child_node() Date: Tue, 4 Jun 2024 19:15:51 +0300 Message-ID: <20240604161551.2409910-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The documentation for device_get_named_child_node() mentions this important point: " The caller is responsible for calling fwnode_handle_put() on the returned fwnode pointer. " Add fwnode_handle_put() to avoid leaked references. Fixes: 1e264f9d2918 ("net: dsa: qca8k: add LEDs basic support") Signed-off-by: Andy Shevchenko --- drivers/net/dsa/qca/qca8k-leds.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c index 811ebeeff4ed..ef529615237c 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -431,8 +431,10 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d", priv->internal_mdio_bus->id, port_num); - if (!init_data.devicename) + if (!init_data.devicename) { + fwnode_handle_put(leds); return -ENOMEM; + } ret = devm_led_classdev_register_ext(priv->dev, &port_led->cdev, &init_data); if (ret) @@ -441,6 +443,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p kfree(init_data.devicename); } + fwnode_handle_put(leds); return 0; } @@ -471,9 +474,13 @@ qca8k_setup_led_ctrl(struct qca8k_priv *priv) * the correct port for LED setup. */ ret = qca8k_parse_port_leds(priv, port, qca8k_port_to_phy(port_num)); - if (ret) + if (ret) { + fwnode_handle_put(port); + fwnode_handle_put(ports); return ret; + } } + fwnode_handle_put(ports); return 0; } -- 2.43.0.rc1.1336.g36b5255a03ac