Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp824780imu; Tue, 27 Nov 2018 23:31:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/WtISMDgDpRZbz08txB0eItUHQvs6aFZeC5tu+Ua781QLw9tQULqIZUkfzGotX/OqpUmW/I X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr36145945plb.263.1543390285871; Tue, 27 Nov 2018 23:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543390285; cv=none; d=google.com; s=arc-20160816; b=n1/CKE/rav0jjQpLxKOKX/G8dFm3W8XR7u/JnNdioBcVeh+3ovOPCfY5C0h3HqTTHy 2QCZ5Q3CzyqTYWAtgboSY/B+GGmNPh7eK0Pc17XIMofY4cWUnpIIGugTnyuiJb60dQk1 8ONcY5VOmuMC88SjeNvr1x6L6thIWCiMi6CFeC4IYMc6qS6Puys8ZMaVPZFcWwRGuVvL rIaKMtSjGqGBmxDscMNrqQvHmZ01ePNmsS2C0g74ujpzvzulm80Tdlqp6IuJjQDdLlBw x2O7bClISe/LSs7jCvez3EvVObl4H41I867TWZs0TM3IPcoxLDf0nEkmg3gAmGDSrD3M XmNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=0evaRUq/nKOncJk2cMDbzNc1vvxAMQ1qEDMmFiVl9Q4=; b=dvtzza7dWhboyV7LqA+l3cczYMqGj+c87aT2bnxvPLFKBMDb2RMOGz+lhyIrdoL6PJ bRB6qQy3yJvbuowuHmxveH6EZO4jKPkbCo3hLtJ9SmoJVvqo39cA3ybjYvleKle/YfFG Nm0NGK1NjnGIv3JRvTO0KqSzOruhV+mYxHREEyMtBhkdNLxOwsJL5V+bVsZz+SO7lA7o vuLQBUVAVMi3zwTY9QyJ4U3uX8HxEczFz/R6sZduYQqybXl6fwWCZikB/I2ed6W1sa3g WAjAE5a3cens1qcFL91Nd6yIOG5gCypdLojyOGLLInW7BHm7hznFMBqoITZk0ODHSplM IXxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=lth4dyGp; 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 b2si6088259pgq.275.2018.11.27.23.31.11; Tue, 27 Nov 2018 23:31:25 -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=@163.com header.s=s110527 header.b=lth4dyGp; 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 S1727641AbeK1SbQ (ORCPT + 99 others); Wed, 28 Nov 2018 13:31:16 -0500 Received: from m12-11.163.com ([220.181.12.11]:37673 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbeK1SbQ (ORCPT ); Wed, 28 Nov 2018 13:31:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=0evaRUq/nKOncJk2cM DbzNc1vvxAMQ1qEDMmFiVl9Q4=; b=lth4dyGpSfI1KixRe2YgN3OAHBAQzZwr3u aHOpgilKXPTYcHP5NCMNc1916d4s0Z66jy2ugP2t62CR6ohRn/vZyuxmnpj+Od1O D22Ug+6tVftTUrwNIOfoth9XdLB3Lqvn9QOJq0jgXb4Vs7HRHjcakyToKYyqpsFy EJ0ERyfd8= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp7 (Coremail) with SMTP id C8CowAA3Do8PRP5bllpLCQ--.43558S3; Wed, 28 Nov 2018 15:30:29 +0800 (CST) From: Pan Bian To: Yisen Zhuang , Salil Mehta , "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] net: hisilicon: remove unexpected free_netdev Date: Wed, 28 Nov 2018 15:30:24 +0800 Message-Id: <1543390224-923-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: C8CowAA3Do8PRP5bllpLCQ--.43558S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrur18Ar45KryfWFWkZr45GFg_yoW3twb_Kr 109Fs7Crs5tFyYkw45ArWDZ3y09F1qgw1rZF43K39xJa47AryUXw1kur4kAr1DWw43Zasx GrsrWF4Sy3y2gjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0F4iUUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiNhUNclWBcXEprAAAsN Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The net device ndev is freed via free_netdev when failing to register the device. The control flow then jumps to the error handling code block. ndev is used and freed again. Resulting in a use-after-free bug. Signed-off-by: Pan Bian --- drivers/net/ethernet/hisilicon/hip04_eth.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c index be268dc..f9a4e76 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -915,10 +915,8 @@ static int hip04_mac_probe(struct platform_device *pdev) } ret = register_netdev(ndev); - if (ret) { - free_netdev(ndev); + if (ret) goto alloc_fail; - } return 0; -- 2.7.4