Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2674366ybl; Thu, 29 Aug 2019 11:17:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXpLAELvQHBj2MqMoplq+OZI1XFq4lQk963F2ByesPwjh2kHFfSfCq7IDLmmxJZjflAWSt X-Received: by 2002:a17:90a:8081:: with SMTP id c1mr11565752pjn.62.1567102670942; Thu, 29 Aug 2019 11:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567102670; cv=none; d=google.com; s=arc-20160816; b=UwuBs/I8cCZDNAfWn/2oOqlBvTUOx75xobVbguQ+EeQzJrDrDUN3EecKZTz+gwhh4g oRoyTtixAaeO8Y/a2TfUXLnMjE8aKVrTrODlUWPxzvoOe0vwGCG9kBYMg7i/ceNoLdcN spZmvVonmaPqvILwDZ0YRaSza90BcRstKC8IS0SsiJ6Ty1il0gjLWXiFMl0UF1gyWslG 6yH4saVSGknsIGbbG7ASu+jATNeJfLwdRmHwhmUDt7Si40uFGUg/cpll2HIalKAI+QJ7 xG0pYewX8V8zk8IM87h58E15qHVIf47GOHTrUCKA1IFsqdLFK/2nTCINA1MEJW0eGAdk oTnQ== 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:date:subject:cc:to:from :dkim-signature; bh=f18ss7PWUY5d3cFMVzMgWh3TM0r6NmNwwjYIA8gPVOc=; b=eZxRlxFx2WYdysF+YHsgn1Km1jtzbPbNx0MKz3nAgqtkoxZbz1uWqb5UPJkTDsNpkI T/Ak33s7PhIaoUkNn5nkV/O+Dmv2RM2OCY58QE7sifePYUZjsOQPhs1RScr6qylBcdim MOnATN5ZonnpNfx1HeuneiqklN2XtQ2egEvCxidso5LWkKbLXC/avwr6KHqgHcAvM6a2 SE/qdN44XUBWf1jhzn3dnUPqmbk3X2gGfFZ2GZcbcpacOO8c7f6Jsoy/Ut55HHc2kFYc uXz4E59TSzRv+tN+t38Ach1TxGncz8nG9y140jcz03avl7VepY+7hPY7SzdhZdcLs05J ry+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j5xapk0u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si2667416pgq.586.2019.08.29.11.17.35; Thu, 29 Aug 2019 11:17:50 -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=j5xapk0u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729019AbfH2SOu (ORCPT + 99 others); Thu, 29 Aug 2019 14:14:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:56332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728959AbfH2SOn (ORCPT ); Thu, 29 Aug 2019 14:14:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65C8523403; Thu, 29 Aug 2019 18:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102482; bh=qml2xfq2Vm0bbYh1zjkEGVJTy8eTz1McNIzEeQePNaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j5xapk0u44rpB/F/JfNaWJpWSwhgQNoqzC0J/M6CgCgsuHecgI73GLvMGWkLiL06K u4VQNvVeyMvS/wALYinN9jKVT5xNo847hFh4Cq5ACDm3HHaRAiLQix46wtoz3bV9Av eBPxfeRd6u+Al0CurVacwf8zEVil5Aw76pDNgB5c= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wenwen Wang , "David S . Miller" , Sasha Levin , linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 42/76] net: kalmia: fix memory leaks Date: Thu, 29 Aug 2019 14:12:37 -0400 Message-Id: <20190829181311.7562-42-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang [ 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 d62b6706a5376..fc5895f85cee2 100644 --- a/drivers/net/usb/kalmia.c +++ b/drivers/net/usb/kalmia.c @@ -113,16 +113,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