From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 02FC51F7582; Tue, 17 Dec 2024 17:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456149; cv=none; b=S4Sf5aMNn0UhTj2tzK/ZECn1fz4DS71hmrtW+fdXtP8XqhSSkJTEv129cuQysVVc4VmlG82OVdWxEyRmNuEfDM/ZcxDOL7oMzJXB4P9IpjOxYuXFIhps9LyGKKrEkoC/MHOxyrQy86dkcjCX/ycbDop/o2t7g6QGu5EtD8mArV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456149; c=relaxed/simple; bh=+ocTHulKz9ccnPYBvAxsObeEqEjVmrDalSYuh3gCzwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uqwQQcGBkthVqj92i4tkFTPPbjOqqk9boxShIJPqeCoLFk5S4qBwDNdmc6Ln/Bc1ldxNT5Mgcz0hBEg4TvtJMh7NeCmUA8f3ahIQhAeJggx0o/OhRNFVqurFVMe+CjXwyegecx3n1z9YdiHdde+4cz4O250p1XN/kdg0hCa+tSs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pjB4J6an; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pjB4J6an" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D857C4CED7; Tue, 17 Dec 2024 17:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734456145; bh=+ocTHulKz9ccnPYBvAxsObeEqEjVmrDalSYuh3gCzwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjB4J6anhbZn9zfHpUClr4pmLP72ee/9lrTYNa2i6Vd2MXrScdlNgJewQVAm/UMeL WbBr8ujzVOPEgjomlDZRraM7hMzSgwu3dem47Xyz3HETlaB6fhQe0kUb8RBueka50e kLcSFaq+5dNxfadK3tAKXcpmvEJaVBxq9PdVCdXE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Yushchenko , Yoshihiro Shimoda , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 076/109] net: renesas: rswitch: avoid use-after-put for a device tree node Date: Tue, 17 Dec 2024 18:08:00 +0100 Message-ID: <20241217170536.559728427@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241217170533.329523616@linuxfoundation.org> References: <20241217170533.329523616@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Yushchenko [ Upstream commit 66b7e9f85b8459c823b11e9af69dbf4be5eb6be8 ] The device tree node saved in the rswitch_device structure is used at several driver locations. So passing this node to of_node_put() after the first use is wrong. Move of_node_put() for this node to exit paths. Fixes: b46f1e579329 ("net: renesas: rswitch: Simplify struct phy * handling") Signed-off-by: Nikita Yushchenko Reviewed-by: Yoshihiro Shimoda Link: https://patch.msgid.link/20241208095004.69468-5-nikita.yoush@cogentembedded.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/renesas/rswitch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index b1432ca79f1e..d04a79ece698 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1819,7 +1819,6 @@ static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index rdev->np_port = rswitch_get_port_node(rdev); rdev->disabled = !rdev->np_port; err = of_get_ethdev_address(rdev->np_port, ndev); - of_node_put(rdev->np_port); if (err) { if (is_valid_ether_addr(rdev->etha->mac_addr)) eth_hw_addr_set(ndev, rdev->etha->mac_addr); @@ -1849,6 +1848,7 @@ static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index out_rxdmac: out_get_params: + of_node_put(rdev->np_port); netif_napi_del(&rdev->napi); free_netdev(ndev); @@ -1862,6 +1862,7 @@ static void rswitch_device_free(struct rswitch_private *priv, unsigned int index rswitch_txdmac_free(ndev); rswitch_rxdmac_free(ndev); + of_node_put(rdev->np_port); netif_napi_del(&rdev->napi); free_netdev(ndev); } -- 2.39.5