Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4122436ybe; Mon, 9 Sep 2019 04:42:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfqwfbrWRvxaMHp1Y5a2MJ1TKx3D12jE1WMJxuOZukC8Iw//2ykj6vCG6JXmxKljMUgbxU X-Received: by 2002:aa7:ca41:: with SMTP id j1mr23626838edt.63.1568029326150; Mon, 09 Sep 2019 04:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568029326; cv=none; d=google.com; s=arc-20160816; b=Gl9TBUIV6fnmAt8D5r9LFvnG5iLATMmSaup5a4U0ODaiSVLfNAFXtWZlkazjf/+S+b s4RQjM4lrBzlXapHUJxQKKj7MvMw781z1ZPfY8W+PJNka43MmutY/xM4Q/r7/v+R6jAY 25MVSW8oFKD+SV5SeXZt8jD9//9C9HROr50yVgEv4WFE3uI8DrZTQLBrMiiir5f66TKT lSy9aBVZ2zP+jFfxWausL9Z7wkmDCIw4Ks33CmwOQfApZuG73jA/Ou4Jy3oo7uLpcPZg tmOqHDmaXGunKIfPBrKnRm1Xqzvwxqu5VswhdoJFK9Xp2/EPEYwRJcxBXcYzCcvY2mV8 UNuA== 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=hUHU74wvl31nxE90jyfOayJPScfG3P/FyWg/hwN4Uio=; b=fV8znsImmzjywNlQBlIA/tZRvPvPbW+xEbZ4SDtuQfPGmIfwShmeXc6LDJ32a7ivfC iH7YUt7poYP+bV+mW1frsh98s7ysPQc0agREw68dT/2uXmpd6yZhk2UMic3QBC6eGkUM JtKQDtzJJQlbyCiYEmjDzQhT0x6wNfKX1Sty10oh4jokZ1AjnH2e8n+1FvMu8rrVARWD ye/76mtjFQ80zT+vrfAIkMqOjMum+goUSDa8QgWClodHyVjvNcVB68g48Dii5vs31dp1 GdOltEJXsQ2V3Q2NvTx2mLjulNjZs8oh1I1TALubJn4wZHMTqtd67J87QAmJ9cpQE5MK uwOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TkYQDLlc; 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 e46si8317993eda.401.2019.09.09.04.41.42; Mon, 09 Sep 2019 04:42:06 -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=TkYQDLlc; 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 S1730953AbfIHMsS (ORCPT + 99 others); Sun, 8 Sep 2019 08:48:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:37246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730906AbfIHMsO (ORCPT ); Sun, 8 Sep 2019 08:48:14 -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 D069A218AC; Sun, 8 Sep 2019 12:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946894; bh=HcGSro/bVINMTqXcmyDPCbmvI42TSvHeyoJFat3J3Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TkYQDLlcy7uSlqlRmldDKvVFlmbgpwK/6StmxD6CMGTe8QAq6E26EYlKjjbxiPtjb r999dA+zDtwxpvMTfyKdTG4Drxc2oGUqtZ+GqM56KxD9/re3DZzS9I0haL7vKmPA8W 1yXdsVcmsRPKcHQRcQMv3unKgpOP1lf75C2LgG7U= 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.19 33/57] net: kalmia: fix memory leaks Date: Sun, 8 Sep 2019 13:41:57 +0100 Message-Id: <20190908121140.283695606@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121125.608195329@linuxfoundation.org> References: <20190908121125.608195329@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 bd2ba36590288..0cc6993c279a2 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, ARRAY_SIZE(init_msg_1), 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, ARRAY_SIZE(init_msg_2), 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