Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp464182ybl; Tue, 28 Jan 2020 06:22:45 -0800 (PST) X-Google-Smtp-Source: APXvYqy0j4WMGacs+RmNjJs41fCpudJQhppe2Ki8y4o5B8DM2wDVE8nPsbL8/c4m4DDNw0cWIl2f X-Received: by 2002:aca:48cd:: with SMTP id v196mr3050504oia.102.1580221365187; Tue, 28 Jan 2020 06:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221365; cv=none; d=google.com; s=arc-20160816; b=Ek5R8Xi/DnknjrfKvukazjn3J5Q9WvU6R1ykFIINSKPFeKs4xAw/SihW5KDkiqLgtS TjqnQtmE+pQMz2d/zbqrD4jGOQouVjqxrtzbSVEBDgEtkQuE5SgVN6zYDKy9yAmf9Kis D+tIu2qyj6NB1KvLRuivIHfIWbfP3RLVsea8qVIDn5MpC5oF9bzOYZDIHrC2stzLYxIG 814bj3F7SYpgiOzaq+8SM9C1KocAAl0JE07IdLCbXBmJjd4qdRQXEiywZWBBWA2JFnb1 HLVFRIXautNx6qUyHGu1YlqBCU2p1Pu3m91PSrMu8j+DQirLQCBhwuezna1R1P1WaYst NGLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mA/iK8U2dI+5jCudsQNZkywcajlzUS9szyncKxeNtig=; b=iWSzaSCzxeNcboXYZHxdPYNwvFhAJQAAX92qcpMrIInN7pQns4u4Zx/vjaVIbJpK/K z3h2plsdKSe78SYZmex4YZdeX6AHeADeg0IDLeLOLEmsoA+zGOwnh2i5ZxCGeAyniPTO VLfgo21m/3sS43p4QxzgsZ/9wjFVE4Fw333wo+TLJCenWDfJkjOVBBlTqlcLSHQkyTyr hdnlkvt73UNg9We9bKaGo7o7d23dShptsWxOgV3w3ruje8XSvCVyZIE6JxcZAWSQjiAl bVETyuRwBXg4Nx1suRc8g046SpZspMXFYKL0HnVT1fJp0pOKUzauoXZ9zRYtGYV6KEv8 vhUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZM/RK3bQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si8759578otk.62.2020.01.28.06.22.33; Tue, 28 Jan 2020 06:22:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZM/RK3bQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731365AbgA1OVl (ORCPT + 99 others); Tue, 28 Jan 2020 09:21:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:47060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731342AbgA1OVj (ORCPT ); Tue, 28 Jan 2020 09:21:39 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D7B124698; Tue, 28 Jan 2020 14:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221298; bh=Sfmb2ZdL6ft6NwPcDPR+ZaOaJpdV1GTSVQsBMSNrpCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZM/RK3bQBvzhps2avMxtnbLv+TrCZB/ufuLLYSlqboJo8ItFqw5EW0LuQhl4l/cjn LeaFTfmgeT4VQGGyAscOKpLQPRm1vUjcwoNA6ES3/qWiluDyVdh5tDYLxI5sMEiKNC dhWZ/8webtVTZ/PDWfJoZIPR+9RPFzTmJARcRB9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , "David S. Miller" , Thomas Gleixner , Luis Chamberlain , Michael Ellerman , netdev@vger.kernel.org, Sasha Levin Subject: [PATCH 4.9 168/271] net: pasemi: fix an use-after-free in pasemi_mac_phy_init() Date: Tue, 28 Jan 2020 15:05:17 +0100 Message-Id: <20200128135905.085190126@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wen Yang [ Upstream commit faf5577f2498cea23011b5c785ef853ded22700b ] The phy_dn variable is still being used in of_phy_connect() after the of_node_put() call, which may result in use-after-free. Fixes: 1dd2d06c0459 ("net: Rework pasemi_mac driver to use of_mdio infrastructure") Signed-off-by: Wen Yang Cc: "David S. Miller" Cc: Thomas Gleixner Cc: Luis Chamberlain Cc: Michael Ellerman Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/pasemi/pasemi_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 2f4a837f0d6ad..dcd56ac687482 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c @@ -1053,7 +1053,6 @@ static int pasemi_mac_phy_init(struct net_device *dev) dn = pci_device_to_OF_node(mac->pdev); phy_dn = of_parse_phandle(dn, "phy-handle", 0); - of_node_put(phy_dn); mac->link = 0; mac->speed = 0; @@ -1062,6 +1061,7 @@ static int pasemi_mac_phy_init(struct net_device *dev) phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0, PHY_INTERFACE_MODE_SGMII); + of_node_put(phy_dn); if (!phydev) { printk(KERN_ERR "%s: Could not attach to phy\n", dev->name); return -ENODEV; -- 2.20.1