Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp934896rbd; Fri, 23 Feb 2024 08:02:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgjL4MPUztz4edhVXJ1sUaifvkGGkcyvwziZvbO9bEM1UeFnvboZfGyVogO1YUPE9IoBhF3nqi+6MRAoLGLN9t0VGPpwi1bfBU4xs/Zw== X-Google-Smtp-Source: AGHT+IGJnohmfcmOCKovxUWLSK6b51CUZsQfAcFqdxBe/wg7lJsGZmN1IH/iobhWpys5m93Yb22m X-Received: by 2002:a17:903:1d0:b0:1dc:6b26:d1cd with SMTP id e16-20020a17090301d000b001dc6b26d1cdmr254638plh.2.1708704133939; Fri, 23 Feb 2024 08:02:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708704133; cv=pass; d=google.com; s=arc-20160816; b=LiEv+4U4jvhSbWCV/GPQAngPSopAB0/lXqZ/1OhiQUTHzsU89IGkH8C9uJ5OksPE1E fvgBwznDBKxwspKoWEr8mHQCkjG6YtSsDwe5TrtaE1JJAnSlVpUcKmO25E6ikhKavxxt nQ2yNMJWXH99KsUybAOEvD6VADrAUMPs+W4jlTV44WrxNvvSioMrTXU7eguyZyzSbLu3 /AEcYk00rd16sNSPtlrh3NP8lVG1XfQ9XqpEbGw5HZQilnZzQBOkO6Iz+JLzIEExTwbm tgBtLGZurCDYfjkmeBfOMaPB/JOduj0JLCRfEsd8SZOaoKHt6rybmVnC3zlr2fn6ZMWh heKg== 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=wuOxqHDRO4c85kOWnz8YWbV2JxBU725ZE17Xns/ymXY=; fh=9/3HQUaYeJmsNEVms9NamWsbvU3izTXvPSaAmr5479A=; b=xZfQCRrTH/wcwC83GxPmquOc2H70jhr/V0v447MWNNFsyDgpgNYV7GlAEQcHcOo5rx AGQXGu20nDiblyLhnwpjML5EllM5PHo3MEHEEQqlCf4peAMDYqxSEsytmv9HMNH6qAjx KKzGG2d9MwN6omv6GzDaoudbRPXTEKbnPcKEUY2iTYmv6d++Zh5jkiNgmI5Cl/7Vy9yq dMEj+wKA1dhPBGIx0ehCmG1WNER6ytnYGF5trx37qHZUkFB5wfP5yzRAQxTSWtZs+tVp glAmQ1Vfk4IBx7a9jJ8/+YwnM30tI5Tr2X/AFkqqZbn43Kvq39XPcVW7kAusjpSAhU0+ AhLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HYmO3Zcf; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-78661-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j9-20020a170903024900b001db603f6482si12603305plh.415.2024.02.23.08.02.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 08:02:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78661-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HYmO3Zcf; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-78661-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9524228542A for ; Fri, 23 Feb 2024 16:02:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AE0D83CD3; Fri, 23 Feb 2024 16:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HYmO3Zcf" Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 C02EB839E7; Fri, 23 Feb 2024 16:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704124; cv=none; b=ZPctSxAw/uJQ57Cp04qiYSbr9g4o1n/jnAMZJRcYP3Q21XJ9ktbvoTVUeeUXsSWXlcz8D5xdLdjYfgliYOIdc1m2vzU8gjrUi4Z8TNvhlATq4m2Oq33gl2qtLrVavuvVr21ltgz0xFMidnbrZH58Ww9DXjkGykBe2vLgpaFpAQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704124; c=relaxed/simple; bh=q8gayPiwbn3DoQkReGZdNHiZIgysS8TjOWehSXNblhI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o2l4psD7Ee2Rqta784eCTIQzknyk84ZyoVJQNoopX0HndjZFoAflDV+r6XIwSq+k9+/1eHg1qcdXoJNNWYqmMxjnbP0zGfgqt2NbLuuD7kwyrOsmDd/ClCoClQ8QFm80H0gUBkUm8eSBrBDe5KSlzahNvlEJ0U3FUh00u70ZfGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HYmO3Zcf; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 36D7D60003; Fri, 23 Feb 2024 16:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708704120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=wuOxqHDRO4c85kOWnz8YWbV2JxBU725ZE17Xns/ymXY=; b=HYmO3ZcfXfkVIqM0zZfeZ4LXgyhsb578iADrwbLeuQKX6sl6blGv5LMut/OrTSWD72C5v9 Qt7t0PgVqB8XpaIGVXg+XAYEYrluMr3OPhXehMFEYSPnS9nWQGW+loeVPNIwbVla//4v8L Z+XSdAalA0ZtpoAs9bKUJoB/Gk6zDhL9xOC5ngoi1fT11SYkXNikUguAOJxwRd43OcXtGa l3JQcP2F9x+vZY+yXX5tGDDTWM+AuHJ/jkNr9wbtZ6UxC2+B3Z296luzD9ncU0YkAU/Pd3 XgCZE7qYrVXkQTibypvoGd8WewYSLGzUWrf+or7ECSM0mZfu3OVkpxp3+8Z8aw== From: Maxime Chevallier To: Andrew Lunn , Heiner Kallweit , Russell King , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Johan Hovold Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net] net: phy: phy_device: free the phy_device on the phy_device_create error path Date: Fri, 23 Feb 2024 17:01:54 +0100 Message-ID: <20240223160155.861528-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: maxime.chevallier@bootlin.com When error'ing out from phy_device_create(), the previously kzalloc'd "dev" pointer gets overwritten with an error pointer, without freeing it beforehand, thus leaking the allocated phy_device. Add the missing kfree back. Fixes: d02cbc461361 ("net: phy: fix memory leak in device-create error path") Signed-off-by: Maxime Chevallier --- drivers/net/phy/phy_device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 3611ea64875e..2b4d04e3d479 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -711,6 +711,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, if (ret) { put_device(&mdiodev->dev); + kfree(dev); dev = ERR_PTR(ret); } -- 2.43.2