From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83E44C433E2 for ; Tue, 1 Sep 2020 16:34:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 529DA2065F for ; Tue, 1 Sep 2020 16:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598978064; bh=zJghPqTOz4KjJypckMiUtZEKpqYq+gHKZcLST6AiYMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=F/83VYOnZV6Pe0XP/x3RERsk2OUhX/leaRD4fQYpUBCVCgZ65QNvqDu3mLamiToU1 OdN/yuK8OEZMadJeLZZeQgCHju7X7CE63W47mFwYiweaMih0yFowTc+FfMuyPKA57B 4hYFAYeEBYqSzFtuazuz4ul0SVeVRvmJFJD4BNAQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730823AbgIAQeW (ORCPT ); Tue, 1 Sep 2020 12:34:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730483AbgIAPbO (ORCPT ); Tue, 1 Sep 2020 11:31:14 -0400 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 E842D20E65; Tue, 1 Sep 2020 15:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974273; bh=zJghPqTOz4KjJypckMiUtZEKpqYq+gHKZcLST6AiYMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XNAqSQhF5xeBy2f5+qLyIP2hcBecYrcRNtCwTtMztPgltNaJz+OxJjy5hbCyby4fi 4MkpA8utT8ZqPpZt2ScBalZJqYd0qLreHKomwBnxj4CedLg4zNEtAbpNh3VAz4AMIx UHiAG3bM6EszBse/O7G+CzMGK0D4XarznRO2rxnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Felipe Balbi , Sasha Levin Subject: [PATCH 5.4 112/214] usb: gadget: f_tcm: Fix some resource leaks in some error paths Date: Tue, 1 Sep 2020 17:09:52 +0200 Message-Id: <20200901150958.351717673@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@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 From: Christophe JAILLET [ Upstream commit 07c8434150f4eb0b65cae288721c8af1080fde17 ] If a memory allocation fails within a 'usb_ep_alloc_request()' call, the already allocated memory must be released. Fix a mix-up in the code and free the correct requests. Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT") Signed-off-by: Christophe JAILLET Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_tcm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 7f01f78b1d238..f6d203fec4955 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -751,12 +751,13 @@ static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream) goto err_sts; return 0; + err_sts: - usb_ep_free_request(fu->ep_status, stream->req_status); - stream->req_status = NULL; -err_out: usb_ep_free_request(fu->ep_out, stream->req_out); stream->req_out = NULL; +err_out: + usb_ep_free_request(fu->ep_in, stream->req_in); + stream->req_in = NULL; out: return -ENOMEM; } -- 2.25.1