From patchwork Wed Jul 6 23:37:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 588054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDF1ECCA482 for ; Wed, 6 Jul 2022 23:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234678AbiGFXhM (ORCPT ); Wed, 6 Jul 2022 19:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234661AbiGFXhH (ORCPT ); Wed, 6 Jul 2022 19:37:07 -0400 Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543DD2CDC9; Wed, 6 Jul 2022 16:37:07 -0700 (PDT) Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 24BA54077F; Wed, 6 Jul 2022 23:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1657150627; bh=W3tGsKXgdwRs/twkzD8FF5EhDgkxWHBsOlMoHb/p1PM=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=GArJC/WUl97fb3nWZ0mwuxUzY42cIaWFioeguUU66TtftiEgAWZ4SBUftPInevBP8 din840CmruWWMKRrm67jEnQaBTtAkNh0zWDr5GGDoihyR/C8RmWqd1AEQkF/OUcOsI dhhtUSPZS0/oDuHnKQfSoNcrDJhqf4dUA55I7KsnbSO0iZfsjSMHz0t7Ja4OIfKIH/ 2Pa9Ol7qetZ6GFtsdsGOU3o9WvM/i0euzyEmatxasD/XM7JlJvJz9Vvnqzrk4axrJr XYyr4D15KUac+voU1GFLeUacvHyaaB/1/+y85uIFVhv0s+V5gsthbJB56wG+w7I71g j0jjLacMmtgIQ== Received: from te-lab16-v2 (nanobot.internal.synopsys.com [10.204.48.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id D76F0A006F; Wed, 6 Jul 2022 23:37:04 +0000 (UTC) Received: by te-lab16-v2 (sSMTP sendmail emulation); Wed, 06 Jul 2022 16:37:04 -0700 Date: Wed, 06 Jul 2022 16:37:04 -0700 Message-Id: <73f6f1ed35feba3db337124a860bd2c89817db0e.1657149962.git.Thinh.Nguyen@synopsys.com> In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [PATCH 26/36] usb: gadget: f_tcm: Don't free command immediately To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , linux-usb@vger.kernel.org, Dmitry Bogdanov , Mike Christie , Nicholas Bellinger , "Martin K. Petersen" , Roman Bolshakov Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Andrzej Pietrasiewicz , Sebastian Andrzej Siewior Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Don't prematurely free the command. Wait for the status completion of the sense status. It can be freed then. Otherwise we will double-free the command. Fixes: cff834c16d23 ("usb-gadget/tcm: Convert to TARGET_SCF_ACK_KREF I/O krefs") Signed-off-by: Thinh Nguyen --- drivers/usb/gadget/function/f_tcm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 53b178ad4f90..cace5746c0f9 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1045,7 +1045,6 @@ static void usbg_cmd_work(struct work_struct *work) out: transport_send_check_condition_and_sense(se_cmd, TCM_UNSUPPORTED_SCSI_OPCODE, 1); - transport_generic_free_cmd(&cmd->se_cmd, 0); } static struct usbg_cmd *usbg_get_cmd(struct f_uas *fu,