Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4311194pxu; Tue, 1 Dec 2020 01:35:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqVuP1m3tanWf51EQuaImYXYeACjZ69slhmaWX1ZagaVX2kBmZzIzroEXMf83goOZhURve X-Received: by 2002:a17:906:edc4:: with SMTP id sb4mr168132ejb.21.1606815351165; Tue, 01 Dec 2020 01:35:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606815351; cv=none; d=google.com; s=arc-20160816; b=nuZD9RmCquLFKkoCSFdvb9KoeEWY19PI0xvOUVT3L0oOeYAzgoCz4Bu+/CCkNy9CyE c71aSKOC3YPgUutC8E0cPG8cGtWwZDr0koCIE8JQ6plpqV79kio/nRxcIqnmEELHJT5p pwYe0fPl/MmCbbRh2J/mI0utiqdGbeaoEwqFyP8xO7fSVcMCjMHuYmKpWrOWKfGBAgJZ cg1NbFf2i62/iI2bBEBwpi8zw+32ckxp6E4IPti8ZMV91X6CU9yY9mGMkTkBhUxL91G1 cBzl8ejtFO9NkgXGUmdiKRzPLmQJHHndq0YyCiF8p2FIVjVhB88E9ctKcY2KxLyWGrPe Syzg== 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=CMjF/fEips1bke0xq8kOTc5LWuiL2NfRjl79/CGgf8M=; b=IPqZGA0hu+ADvwX4DIzlTmydKizvzIPGnejiq9J2j7zwd8KOp/hC00rp+0FzgQYDoD pW0s0PDrAlhn33UNQJKDBwMHoD0yhSAysSMqjL/lCdtbg76IPI6NC5zK5gIcJk6Elo1a 1HyFyaCC+M9GjjKxQS502NubDPhRzICyTXyE4KP43sMlhLnhykddvROp4+Hcft7+FiGF 3dsKXI5ZZIHxHPaCsep6iIedxMQtJub8q99smWt5/JvhBATbwsKBCp6JcXi10yK1EvSH Q5q/rZg5bs0VdHDsChK8FS+QgMTeHJHhYaKZdPeUrfTU17GREIx3a7SQqvqIyz1Qbwu4 I35w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AQ9zcuXp; 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 a13si591818ejc.128.2020.12.01.01.35.28; Tue, 01 Dec 2020 01:35:51 -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=AQ9zcuXp; 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 S2388097AbgLAJbQ (ORCPT + 99 others); Tue, 1 Dec 2020 04:31:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:34600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388084AbgLAI7M (ORCPT ); Tue, 1 Dec 2020 03:59:12 -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 1B6FE22240; Tue, 1 Dec 2020 08:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813136; bh=tu6S5zgCnZG8HdLQNP488Gv9DGe4mda5+Nyyhuwd5so=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQ9zcuXpGBrHVEgWqxdx7/l2DuV6i0nOml1JCWgTx466A4p6lPEFM1mX+k4rN3UuC ivjg9+T84eGmUV4clvH/V16RqlMYcK2UAGyKoIw0BtvZe3uWyP3+YCUaRjWD8hnwLX vbS4y44BxTTNv1tgOhI8Aq5ngmxoRzYSdweY7H6E= 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 4.14 45/50] usb: gadget: Fix memleak in gadgetfs_fill_super Date: Tue, 1 Dec 2020 09:53:44 +0100 Message-Id: <20201201084650.374952400@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@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 @@ -2044,6 +2044,9 @@ gadgetfs_fill_super (struct super_block return 0; Enomem: + kfree(CHIP); + CHIP = NULL; + return -ENOMEM; }