Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1267227ybl; Wed, 14 Aug 2019 13:44:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwByVmk+wLjJpl9REnGQdTEreYtwxy6mm7teoI+LvWJZf2xOy1PXj4uaR8TjQ81VswDnpjA X-Received: by 2002:a65:4841:: with SMTP id i1mr858977pgs.316.1565815474322; Wed, 14 Aug 2019 13:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565815474; cv=none; d=google.com; s=arc-20160816; b=CYMyjJibmuaPiknVCwWTroDUCFXk/JphwbyS50kn6aXWuvJ1noRUdAWRm7MmHJ6xYg D4bRQJglK/mitPJYI0aqPYr75gvb+HXtNV4bj9WDoR5F5iXpBhaUSaH/rvtFUMwzGPQU 6I09OWmI/Spj64r9KwngF+egutfhuFXAS+vZ9opXc5dZf5SgFWfaO3Cv9Iz367PFdB8L +QFt/x3iapX5GqVnqUyY/DjXKLDXYTRb1zswyJ0nMcwypKDML128xnRi8M82gN/G0ZtJ 0ir65eA872G8R7P77oZzzIwdQ82J7qx542OKAqguGR6WmGlj5OH/J22eNUigjGfpotd4 z+cg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=+VxcUkgMv5C6Owq6hhiGOKhlX0kBsP7MBfCttk6k1Us=; b=unxMoZBpnwe/13hU+nfiBZr04hAE1PQG40zCCYQ1PijPTg1VchfgQthpKklRg0UISJ uTKyeiOroLs0gcNfbbh4bBjiftEBpM2HHbGFAcqz7U6sh88X7g/v/W5bc0rU+iD1d6tD Sz8ILDQwALX7P4kWX9nUDaJvhWBSmRVH2dLqj2S2MLEBI40WXua6HGKe+gD6cRzaW3Hp wJu44cUVXBpog3SXDUFF5CykF1NMEjeqCFKv08QTdNA6oJ9YuFSQbMKl+euslpZOXCak ar2bAIGkkkYnB58TqA/0HXKThZCk0f84d3GCperoSH4OaEB/6u1puqNJaQtIXhHM8SGe gJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=0IUppGsD; 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 a15si438303pfi.48.2019.08.14.13.44.18; Wed, 14 Aug 2019 13:44:34 -0700 (PDT) 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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=0IUppGsD; 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 S1725895AbfHNUh0 (ORCPT + 99 others); Wed, 14 Aug 2019 16:37:26 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40073 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728432AbfHNUhZ (ORCPT ); Wed, 14 Aug 2019 16:37:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id w16so38262pfn.7 for ; Wed, 14 Aug 2019 13:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+VxcUkgMv5C6Owq6hhiGOKhlX0kBsP7MBfCttk6k1Us=; b=0IUppGsDxlHyQcKfLHuFd0H0tqux2bMDBNt+M9ss0PCKz5bACHobFhyOYp7Zj4EC1j 9epvFIDrmlrsbzOUTkzM6YF/E8jZE/MKCPg1ByTtJ9FKnZJZPbOhafwVlAd1gARv0LnG IWcJuHoG0RxHuF0MnRIhMEMp2SRfyezE5FbAbKV/WLSJx2RdYZ70zDq3c+RoJpoq9EWh Wg5XNdDlCBBFnPig0ysqw4ZY7RW83xnu2TZFbBtry88P+W2HWhp1/hgX51AiuTONehOW bbaFLkj/CwBagVuF5Kip4D246zK0MK4Uy/dbMoEgmsAqRL7Qgqcc2Z+Trlftw6MYCaSA ZF0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+VxcUkgMv5C6Owq6hhiGOKhlX0kBsP7MBfCttk6k1Us=; b=jTwmxt/GctzWQX3VYP8Oy1EJ84MMRJ4ChShFr70hFe0xekrtpfeiKsJyR0SDyYcQ6u 3ywCDOf9VYeuSjrOywfx5OUG0AdSxq18FOPomTbFOabFz+MUDl0uNBZngNoE1OsMyEcW VxVEiPW2W4r8TFw81svek4ZNhYFhlFPUcmFAaC41F0QCR9f9pJcMlBsPOyGAGZPs9j1e dsQPmUXaWIMSgx5s9lwLiZMZ0Bf45bT5fDpUeqE0LVaIq5Ddk58D9EfCnn2L2KXbk+GN hqit+ZFAS8YPm5M9h8GIaVIEfz1larK5qWGUoFmrvph7l/gd+4XO1dA7MkdQv1k4RBGT m9+g== X-Gm-Message-State: APjAAAVGX4ZrwujV0uy2DbKBfhmJJnaRFo6yapMIpf5DnleUp0oGDUgr O/LXuunyFmtGHDvX8TNTsMWNtg== X-Received: by 2002:a63:e901:: with SMTP id i1mr777506pgh.451.1565815044726; Wed, 14 Aug 2019 13:37:24 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id u18sm767106pfl.29.2019.08.14.13.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:37:24 -0700 (PDT) Date: Wed, 14 Aug 2019 13:37:17 -0700 From: Stephen Hemminger To: Wenwen Wang Cc: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , "David S. Miller" , linux-hyperv@vger.kernel.org (open list:Hyper-V CORE AND DRIVERS), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH] hv_netvsc: Fix a memory leak bug Message-ID: <20190814133717.4172033e@hermes.lan> In-Reply-To: <1565813771-8967-1-git-send-email-wenwen@cs.uga.edu> References: <1565813771-8967-1-git-send-email-wenwen@cs.uga.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Aug 2019 15:16:11 -0500 Wenwen Wang wrote: > In rndis_filter_device_add(), 'rndis_device' is allocated through kzalloc() > by invoking get_rndis_device(). In the following execution, if an error > occurs, the execution will go to the 'err_dev_remv' label. However, the > allocated 'rndis_device' is not deallocated, leading to a memory leak bug. > > Signed-off-by: Wenwen Wang > --- > drivers/net/hyperv/rndis_filter.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c > index 317dbe9..ed35085 100644 > --- a/drivers/net/hyperv/rndis_filter.c > +++ b/drivers/net/hyperv/rndis_filter.c > @@ -1420,6 +1420,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, > > err_dev_remv: > rndis_filter_device_remove(dev, net_device); > + kfree(rndis_device); > return ERR_PTR(ret); > } > The rndis_device is already freed by: rndis_filter_device_remove netvsc_device_remove free_netvsc_device_rcu free_netvsc_device called by rcu static void free_netvsc_device(struct rcu_head *head) { struct netvsc_device *nvdev = container_of(head, struct netvsc_device, rcu); int i; kfree(nvdev->extension); << here