Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp421988pxk; Fri, 11 Sep 2020 10:25:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOSiw4TyfCa2blWKFqYMxWxIpLukMhD3JOQXOfrs6V+ZvD3oUlGX1s4Uoh/+2dIOPnfMoN X-Received: by 2002:a17:906:2458:: with SMTP id a24mr3112418ejb.353.1599845133818; Fri, 11 Sep 2020 10:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599845133; cv=none; d=google.com; s=arc-20160816; b=WBYpzRgl/iqxb/tNKFtiAJOshXzQF8Dc/KMXuyk+ZDwsxPIQUrCl6QBylku15EDX/R YZ4FSO+kbbafbmos+ERRJAo/QQ0tC4X0UVpnjKnwr/aOHhP6HMP6hruyqfsjRTP2c5cr w6Zd53VNgWYW1kV8HrHuzkC2jblGi0mwMymISdPEKli5gHKhUbCr2RWgLq51AFD8aTi3 6qghHuP3kUdBwOvSd1LLV55LrxyM/BR8IUt5D7VFvTHvzF+6S1YOwve5arlDpo5kX8E9 xMAoW/IHv5NKQ15qPNnm7XFmqwS5qwgkuU3oOv9iEurCRUdsM3tcaVoOSpjNU1Mq/E7O EHfg== 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=cyESeyJ70kt7cquVhv908PmHXLuiV2Kifk6JwZdHiQs=; b=NoYShqhhPE9ObPLol6tMyd0/ubTVp0yy0uGIPwRSz2U9whNQ9/D2hmkI0VwJ33PrxY Z2QQEbAGV5vtb88ylulAxHuG8ghn/pcM0rLVr22WoiK136xgLxaZrsqmBizHBBfY+Rgm YHsFSsGUYXZWYoDnw5yTlhg6RmKT+fHCjFIAsVs5iWVJeAZWoHBWEu/A41u3eu2RvcjT R9z/Z/yXQvWjzx89KCHJvu9J7sFgWKTuzJopfsRIJuCJtC2syC4EaB7SiknPjbPK5LeM Dxqpo3rS3ZAWBoa0LnxWrfQxl3WlvYqd9LRfIv0c63/NqO1ygSQmbYDa8o+j3zwBGC/j cNsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IcdqcuaR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si1716528ejt.529.2020.09.11.10.25.10; Fri, 11 Sep 2020 10:25:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IcdqcuaR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbgIKRWg (ORCPT + 99 others); Fri, 11 Sep 2020 13:22:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbgIKNAL (ORCPT ); Fri, 11 Sep 2020 09:00:11 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 06BBA22229; Fri, 11 Sep 2020 12:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828976; bh=RoyFK1P18WX3DYvexX/ai7qTSMM7cszkK3C4fBr7ssQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IcdqcuaRCxcswrppbDyUH62oxjuvTPOMF/tWDb+uPysDQ1qz/uWhBxzkl3zP5BqhZ iHnXqbGoaSoAEumTlK1y9pTEJPlymBTRa/9pmBxF4GtcCWQnQLTWwb665q7mTOcKdp NQP2GoxrzUP2IOFhE7X6Jg+HIVGJdLUwhFYRMNSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 18/71] net: hns: Fix memleak in hns_nic_dev_probe Date: Fri, 11 Sep 2020 14:46:02 +0200 Message-Id: <20200911122505.847138844@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@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: Dinghao Liu [ Upstream commit 100e3345c6e719d2291e1efd5de311cc24bb9c0b ] hns_nic_dev_probe allocates ndev, but not free it on two error handling paths, which may lead to memleak. Fixes: 63434888aaf1b ("net: hns: net: hns: enet adds support of acpi") Signed-off-by: Dinghao Liu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 24a815997ec57..796f81106b432 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -1990,8 +1990,10 @@ static int hns_nic_dev_probe(struct platform_device *pdev) priv->enet_ver = AE_VERSION_1; else if (acpi_dev_found(hns_enet_acpi_match[1].id)) priv->enet_ver = AE_VERSION_2; - else - return -ENXIO; + else { + ret = -ENXIO; + goto out_read_prop_fail; + } /* try to find port-idx-in-ae first */ ret = acpi_node_get_property_reference(dev->fwnode, @@ -2003,7 +2005,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev) priv->fwnode = acpi_fwnode_handle(args.adev); } else { dev_err(dev, "cannot read cfg data from OF or acpi\n"); - return -ENXIO; + ret = -ENXIO; + goto out_read_prop_fail; } ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id); -- 2.25.1