Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1100275ybl; Wed, 14 Aug 2019 10:42:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3u9wcUU9nQIHKGhnYj8vfSoSynCCWtd2Zru9SAaFbkWKM8wpWknmKEbszaux3im6k7fGF X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr832600pji.136.1565804560610; Wed, 14 Aug 2019 10:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565804560; cv=none; d=google.com; s=arc-20160816; b=eX4kj4DwkH6NctZ1ls5Z25ipQ9p2uwtxb0wISjc+9ndns7Mm+pEWYBj9gnUv2Z8Whe VGPVnbERgaKsf0AZWtskpjGZpYpuLJn/9bjcMyxYansTV0qk7m+ZEu96e0EgDB3o5F5q prD3JWyFTaab/PrFa/uXSvDaqrEDyDpBAY9kH3wtlr4k8QJRNXGq1x8pfTNkKiR50ndR VUdZwvfaGN3x4LI3eU3C9cngml2cgYeEej+3sza/1wkJ4eWCawFByBEXOr2+9VgV8kgp wfw44j5OgOq6cALFUnloUGdfGSFADb365xDzxZqd8fdjbVEHf0CNLmF8f2Eq5Yoaa4gX AqLg== 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; bh=sHuMccop5UgrrMj0/XyByQ81In/IvXzzxsdeKT5qeXY=; b=C0OQ5TCEKcvsZ23ugVAkXAIvAyAPS/fN2D53J4MRNJ6Nka7lm9/q6ZW45spKQ5JdFq om/lnbDUqW6kmQkpnuMb4rMOhIdI4Cq35kmvd76u0M/j2JP7IxhqjFHtNHrpX65AHBEV jYuAwHu++RXqwGPZ0c9wTiA+ETRR4XAP7U8Dzh/sBs+s4xQF9dtmFHtX8vyJRE8KBh8x X/g37m7xr7Szf2ZNXX0WCqJqabl8oc775EMtTrf1U2uL9E09mrzf0lwZftQlxvTuRO6D 03+PuxA7yGqfHvwtrkdJxU7TECWAIGsItR16FOD8+FuPTztLeHxNwxQ3yrlp8MI047yB jK6A== ARC-Authentication-Results: i=1; mx.google.com; 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 l62si225912pgd.24.2019.08.14.10.42.24; Wed, 14 Aug 2019 10:42:40 -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; 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 S1728700AbfHNRls (ORCPT + 99 others); Wed, 14 Aug 2019 13:41:48 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:42884 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbfHNRls (ORCPT ); Wed, 14 Aug 2019 13:41:48 -0400 Received: by mail-yw1-f67.google.com with SMTP id z63so41231722ywz.9; Wed, 14 Aug 2019 10:41:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sHuMccop5UgrrMj0/XyByQ81In/IvXzzxsdeKT5qeXY=; b=jdld6SlHNDZmGx5M3pz405dLCUtfNHUjnXWEnLfagn1Zs0CiYAFaJpiv/OUfTUqbD1 BqK2rGZX6O4W9or6Pi14cpxZsPPcUX4oxIvfGcgCI4MM1jHm2MDBYqNxyW6lX/AbLPDV 5zEtnvGeckFaIo3PAKw08h4xjtUA3wijSsvnc81ug4eOBmwXSf97wTyogWTKmCBZ/jiQ 3MGHiS+CjoY4OarSbG3xlmqqQ5ivNtT7ecdkytuXMlFd7mL2fQ7q1cLH9gx7SKdKryvB gAoeNDe7HFtU4Sag7LeWtVigiXvWR2RLxNGJPv6h+WpAUmORDjHO7mC0SzrxiwEFPGoA 0vFg== X-Gm-Message-State: APjAAAXEjuOW/N8+n6IXdf6HdCtZ8PLC4UpsN8eTes13c7jL5MzLrNpr roxFCT3e7mPbCdVy2zmZWfB/sF8Ncbs= X-Received: by 2002:a81:5c87:: with SMTP id q129mr266407ywb.403.1565804507497; Wed, 14 Aug 2019 10:41:47 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id q65sm115032ywc.11.2019.08.14.10.41.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Aug 2019 10:41:46 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Oliver Neukum , "David S. Miller" , netdev@vger.kernel.org (open list:USB "USBNET" DRIVER FRAMEWORK), linux-usb@vger.kernel.org (open list:USB NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] net: usbnet: fix a memory leak bug Date: Wed, 14 Aug 2019 12:41:33 -0500 Message-Id: <1565804493-7758-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In usbnet_start_xmit(), 'urb->sg' is allocated through kmalloc_array() by invoking build_dma_sg(). Later on, if 'CONFIG_PM' is defined and the if branch is taken, the execution will go to the label 'deferred'. However, 'urb->sg' is not deallocated on this execution path, leading to a memory leak bug. Signed-off-by: Wenwen Wang --- drivers/net/usb/usbnet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 72514c4..f17fafa 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1433,6 +1433,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, usb_anchor_urb(urb, &dev->deferred); /* no use to process more packets */ netif_stop_queue(net); + kfree(urb->sg); usb_put_urb(urb); spin_unlock_irqrestore(&dev->txq.lock, flags); netdev_dbg(dev->net, "Delaying transmission for resumption\n"); -- 2.7.4