Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp403642pxu; Tue, 1 Dec 2020 14:23:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2LFZXmO6AKlGo2sClMttppu/UtprThkPiECMRg94R3BHh8ntiZ7doxB6LCrMfWEO+plPS X-Received: by 2002:a50:9f61:: with SMTP id b88mr5460986edf.282.1606861405990; Tue, 01 Dec 2020 14:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861405; cv=none; d=google.com; s=arc-20160816; b=CB3lvsDQNVMWI6UEPLbeAoQRgQb7GnM0MbE5FHJwBS0c3pFXtZR8QWjbLGZR8WGedc fhdBcFSvXNannOomNtyRBd1Wbf7QbC+P6112u0SP/w7KdqpL3mWkNmF9+a6AD+pYPXft FsMsHFXmakm+LikkUPjxxScqCSbE5+IVZcrXbnw+iA+Cp1NDKAv9SvBz3kul11pOnT5m Es0irkHYLtYBZWEy9EbxTDBvez5xeLbZaSXkKCWO0fYYeNuweZhrl7MRZuXW2dLz4bOW NM/FflQqpQHROgqWPDM+Ud9owSIqG044bMbKx3q4TtLPj86eavPtKTdDjElOz4Umf0Br 1z7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3UCwy9Z/29lFWAUtSX5PwT6qAVPSY5sBJf9Y2B0/jwc=; b=eK+5rIzF0+3ccgnPIiNDnTQ7HsPIlgbeZp+eeK8Oip6dzwC6CInIq7OfPtzjDUrpE/ cew9Ox3lXVaImf5XJ+yzv5h2CWhGT/1TmCaEMcOMvXTSilhM+q8SmRTRE7nkgh5D8GyE V/yZlljq5x/6iBpBldkJliP/7OOy4+8ToFupJhHtfLD0YxY8wUeX5EhkbkL40VUOQQLQ nxHUy6teieFSYviudewknomvThY6gshCgXPCPsYGRbt0Amv1cosl6XsSi+1mbnyFx6Vp RvTJdkBn3a07Wyb4VWR7K0wqWH163THNWyfcgIFG+PJRjRGczR+6W94XGNwSP1w1E2ZO /SZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bpzWUsgU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si803402edx.510.2020.12.01.14.23.03; Tue, 01 Dec 2020 14:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bpzWUsgU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389186AbgLAJIR (ORCPT + 99 others); Tue, 1 Dec 2020 04:08:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:43026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389072AbgLAJGZ (ORCPT ); Tue, 1 Dec 2020 04:06:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 AF0FE21D7F; Tue, 1 Dec 2020 09:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813570; bh=flPZjbh2BeNlKedo7Gb7xPO/fGv5DVJFD3xLc1JOyR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bpzWUsgUmMULMrEF+y7lipb7HMaFVCkPYgxlfpa0cwhI9gFbzCyV0LoR/8MYqjVCe wnCmh3KzwTVKhVlETVyMyiZ9430LRE8LQ5wocvOxcvoupDnXmUYR4foNIsSktD1Wkv fuzm2TTl+WldtibE+gqCsIQC/DGUh1De5kKyBkYY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Alan Stern , Zhang Qilong Subject: [PATCH 5.4 84/98] usb: gadget: Fix memleak in gadgetfs_fill_super Date: Tue, 1 Dec 2020 09:54:01 +0100 Message-Id: <20201201084659.164581499@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084652.827177826@linuxfoundation.org> References: <20201201084652.827177826@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong commit 87bed3d7d26c974948a3d6e7176f304b2d41272b upstream. usb_get_gadget_udc_name will alloc memory for CHIP in "Enomem" branch. we should free it before error returns to prevent memleak. Fixes: 175f712119c57 ("usb: gadget: provide interface for legacy gadgets to get UDC name") Reported-by: Hulk Robot Acked-by: Alan Stern Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201117021629.1470544-3-zhangqilong3@huawei.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/legacy/inode.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -2040,6 +2040,9 @@ gadgetfs_fill_super (struct super_block return 0; Enomem: + kfree(CHIP); + CHIP = NULL; + return -ENOMEM; }