From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7CA42D023; Mon, 10 Mar 2025 17:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741629455; cv=none; b=FV6vnpOHNoe+v+l9azwm8GOmX5oPclnKumnWN7Q+lu/q8T8C/9IcqCyk8PvgB3ZnVStWGzaHJ5DbG0tDbaZJGwVE6Av9x7dynkKydJYUn+DozTGfIciJ8rAn36xn8U/bpO9EXUXMQ6FCZWeqNKmwHOQlBsoIzbtiKPUK7RaGsbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741629455; c=relaxed/simple; bh=J4Ksl8s+EO6HtbtHK+EpCYtzdYkT1XMp9VYEPjNA6Ok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bNqxHEjD8xLkZ7OV+29pALNDLGOUFUiZ7GKwhTpn6qfWf4phBwZmZjCCJLZUAp+afqdO4M3ZCSDWrysRSK9zDteEQU2e9CCbHQ7nAqfM10fltXLWiKq3TRe3cvap46SfArIuEvDfNAr3IUbIamXlX1ZlxNPd7nV9AdqFQOfUJ3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WEokRX3D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WEokRX3D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5D29C4CEE5; Mon, 10 Mar 2025 17:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741629455; bh=J4Ksl8s+EO6HtbtHK+EpCYtzdYkT1XMp9VYEPjNA6Ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WEokRX3DGU+37ZQ4g/vcjm/OmEen1e4D8iHWXY84DmsQORmU6Ys1fhA65Amw8GGUP OCMo8RnISPkN9yVXjEPIOCSAyOjy621vxCl0ekxoCbytBgXN37j0ZgEhmtyVwDk4Q7 ai4OD3pikQsBWOt42hNlzdbi43L/NnJxGs/KsXYA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thinh Nguyen Subject: [PATCH 5.15 283/620] usb: gadget: f_tcm: Dont prepare BOT write request twice Date: Mon, 10 Mar 2025 18:02:09 +0100 Message-ID: <20250310170556.785797847@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250310170545.553361750@linuxfoundation.org> References: <20250310170545.553361750@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thinh Nguyen commit 94d9bf671ae314cacc2d7bf96bd233b4abc7cede upstream. The duplicate kmalloc here is causing memory leak. The request preparation in bot_send_write_request is also done in usbg_prepare_w_request. Remove the duplicate work. Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT") Cc: stable@vger.kernel.org Signed-off-by: Thinh Nguyen Link: https://lore.kernel.org/r/f4f26c3d586cde0d46f8c3bcb4e8ae32311b650d.1733876548.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_tcm.c | 17 ----------------- 1 file changed, 17 deletions(-) --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -245,7 +245,6 @@ static int bot_send_write_request(struct { struct f_uas *fu = cmd->fu; struct se_cmd *se_cmd = &cmd->se_cmd; - struct usb_gadget *gadget = fuas_to_gadget(fu); int ret; init_completion(&cmd->write_complete); @@ -256,22 +255,6 @@ static int bot_send_write_request(struct return -EINVAL; } - if (!gadget->sg_supported) { - cmd->data_buf = kmalloc(se_cmd->data_length, GFP_KERNEL); - if (!cmd->data_buf) - return -ENOMEM; - - fu->bot_req_out->buf = cmd->data_buf; - } else { - fu->bot_req_out->buf = NULL; - fu->bot_req_out->num_sgs = se_cmd->t_data_nents; - fu->bot_req_out->sg = se_cmd->t_data_sg; - } - - fu->bot_req_out->complete = usbg_data_write_cmpl; - fu->bot_req_out->length = se_cmd->data_length; - fu->bot_req_out->context = cmd; - ret = usbg_prepare_w_request(cmd, fu->bot_req_out); if (ret) goto cleanup;