Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4034561ybe; Mon, 9 Sep 2019 03:09:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzovUhHYQrEjxZsbvIozOppc/OkEnbT8DAuci/xUS13VOMS8lZZOFMsSbrtMusNDDlZSJZH X-Received: by 2002:a17:907:111b:: with SMTP id qu27mr18889155ejb.10.1568023785258; Mon, 09 Sep 2019 03:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568023785; cv=none; d=google.com; s=arc-20160816; b=cA3t29DV+Jb8o01c5JhMXwKFKNplLk2UVvbFe4EouExh3vAsJhvqJv91teaZa9J9IP NKCT5JF5GcuwIunuPuQoAI/HyoRFunjg4FtCMBAIrvMADbHggVGkbxKEpkOAtqaJPdaA CSmc076/r05XBdUAOTauGaZoQVnwOSBaubkWzmekDidMPuD67pClLt9QflG9faA8B7ue 5afriyQJHy/RusvH4yrVRArIkTFe+O+zz5zt/qYX1rIDSS11FrQ+cszFpKDHgoUxULve BPk4UtQ60DeoFb15/Lt59KvpLwFoBhkHZ8Bh3fUkSC8yGf/owHt60enbdKW5RN+fecPX s3wA== 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=aOcunDaCZiEHEu/4BpGI3rgGg8Y++8wUyiP8RmGaikE=; b=wTacFW6b8YKkvT9vlG3ZEZF1hMBUhK/ZPI2RGbs38nvI9PrG+Wm/OreP59LreHv8aS IYQijq2FMZAmjj4U3YOwK10SUEUfUQwNr6Sa1dbhqro/wJddqTjyzKzW813ebiabLbYc asREocEykVY5tMInhr4VS0q8uLiDQ2vspB8lJQZyubFpaU9yjPZs+BsSSeVpUrcXjpQ3 4fm3YOsDxdcQwbaHyiC1Tl8OmhSOWh9esEKfYZmzF30q4FWch2gs97uUiEnpVKy1DJ1d gSgL5WKMkBpRFYO+rm642ycfVUgaVk4MdzqdBrotlITbP7QqTH2OpqLjfcVSjSur+E8m TL6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="tunCprI/"; 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 z47si8720619edc.30.2019.09.09.03.09.21; Mon, 09 Sep 2019 03:09:45 -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=@kernel.org header.s=default header.b="tunCprI/"; 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 S1729966AbfIHMo7 (ORCPT + 99 others); Sun, 8 Sep 2019 08:44:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:59910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729954AbfIHMo5 (ORCPT ); Sun, 8 Sep 2019 08:44:57 -0400 Received: from localhost (unknown [62.28.240.114]) (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 8CD85218AE; Sun, 8 Sep 2019 12:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946696; bh=eA1UmvITMznGUO3OQCWlkolxcB0kVV3odZ9xjZWeUHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tunCprI/EXKp+G3UWpYmzJ67/TIIIswcBpnIOBLbLqfAS5Ki/+BgpepwjG0U7TPE9 wHWrR4Y5vN/FtL7chXWhoMj19N2gSoJhxrWiNnSoMcTBD3twQgrih6oHPhVNWJ/BSv lasLffunLVXBi5nrWfRjCsdoj1q6E+gXVT8VHzi4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 09/26] net: kalmia: fix memory leaks Date: Sun, 8 Sep 2019 13:41:48 +0100 Message-Id: <20190908121100.592440132@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121057.216802689@linuxfoundation.org> References: <20190908121057.216802689@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 [ Upstream commit f1472cb09f11ddb41d4be84f0650835cb65a9073 ] In kalmia_init_and_get_ethernet_addr(), 'usb_buf' is allocated through kmalloc(). In the following execution, if the 'status' returned by kalmia_send_init_packet() is not 0, 'usb_buf' is not deallocated, leading to memory leaks. To fix this issue, add the 'out' label to free 'usb_buf'. Signed-off-by: Wenwen Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/kalmia.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c index 3e37724d30ae7..0c4f4190c58ee 100644 --- a/drivers/net/usb/kalmia.c +++ b/drivers/net/usb/kalmia.c @@ -117,16 +117,16 @@ kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr) status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_1) / sizeof(init_msg_1[0]), usb_buf, 24); if (status != 0) - return status; + goto out; memcpy(usb_buf, init_msg_2, 12); status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_2) / sizeof(init_msg_2[0]), usb_buf, 28); if (status != 0) - return status; + goto out; memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN); - +out: kfree(usb_buf); return status; } -- 2.20.1