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 967AF267F61 for ; Mon, 28 Jul 2025 13:44:44 +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=1753710284; cv=none; b=GuGKrHAQOTTU9OmABwixJY0hVHmvk6g+hyoy0KrBKG/gl6k+J9W6nYudTteJcBcgTpwgZyxeQ6DH/utvB6H3Uv+hUYpYg8DCwIJD8abtPPHoR6Nln4kQf/JdGh8n3R9w5DOO/Szt8KDJeJRtWQC3Rd0gXX3pwKEwbcOJiA2RMAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753710284; c=relaxed/simple; bh=jFOw+1OrAmHdDiYAwWHlVWmnIaFR4xLt5SzXnaDJo8Y=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=Yw7lOTUMe9Ma6PMxS+382h6auQCJWYr1DZD9MZzVU6sUIst/GHdyH6YdLk+YbBAmV0wXTcugVGYYkyRXp4sLQPc06BFGjhd9NDaxrutvPysemoLdBQ/wMODmz54RF0SxoJL68SFkeqkRp8JkIgkFhivsG9uoMI1gseMnHJ3/Dyc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Azd7ptom; 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="Azd7ptom" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D1CDC4CEE7; Mon, 28 Jul 2025 13:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753710284; bh=jFOw+1OrAmHdDiYAwWHlVWmnIaFR4xLt5SzXnaDJo8Y=; h=Subject:To:Cc:From:Date:From; b=Azd7ptomDvC9B8h2VyWHgWbF9KEtLULFK7f8Opj1sl6zmWUaHpFQJNSkslIRGB0hd Z+BhL7pSVLc/4vWUfwE7AaopmlP5HDcy+dhTyePKS9plSGGx7gjPjN7cT5E/rIad8l BkjlTFLN8L2gshibFLnlfH9RCOI7efO8nTCqPp0I= Subject: FAILED: patch "[PATCH] dpaa2-eth: Fix device reference count leak in MAC endpoint" failed to apply to 5.10-stable tree To: make24@iscas.ac.cn,horms@kernel.org,ioana.ciornei@nxp.com,kuba@kernel.org Cc: From: Date: Mon, 28 Jul 2025 15:44:40 +0200 Message-ID: <2025072840-quickstep-spiny-0e80@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x ee9f3a81ab08dfe0538dbd1746f81fd4d5147fdc # git commit -s git send-email --to '' --in-reply-to '2025072840-quickstep-spiny-0e80@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From ee9f3a81ab08dfe0538dbd1746f81fd4d5147fdc Mon Sep 17 00:00:00 2001 From: Ma Ke Date: Thu, 17 Jul 2025 10:23:08 +0800 Subject: [PATCH] dpaa2-eth: Fix device reference count leak in MAC endpoint handling The fsl_mc_get_endpoint() function uses device_find_child() for localization, which implicitly calls get_device() to increment the device's reference count before returning the pointer. However, the caller dpaa2_eth_connect_mac() fails to properly release this reference in multiple scenarios. We should call put_device() to decrement reference count properly. As comment of device_find_child() says, 'NOTE: you will need to drop the reference with put_device() after use'. Found by code review. Cc: stable@vger.kernel.org Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink") Signed-off-by: Ma Ke Tested-by: Ioana Ciornei Reviewed-by: Ioana Ciornei Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250717022309.3339976-2-make24@iscas.ac.cn Signed-off-by: Jakub Kicinski diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index b82f121cadad..0f4efd505332 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -4666,12 +4666,19 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) return PTR_ERR(dpmac_dev); } - if (IS_ERR(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type) + if (IS_ERR(dpmac_dev)) return 0; + if (dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type) { + err = 0; + goto out_put_device; + } + mac = kzalloc(sizeof(struct dpaa2_mac), GFP_KERNEL); - if (!mac) - return -ENOMEM; + if (!mac) { + err = -ENOMEM; + goto out_put_device; + } mac->mc_dev = dpmac_dev; mac->mc_io = priv->mc_io; @@ -4705,6 +4712,8 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) dpaa2_mac_close(mac); err_free_mac: kfree(mac); +out_put_device: + put_device(&dpmac_dev->dev); return err; }