From patchwork Tue Mar 23 21:24:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12159435 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 1F2D3C433C1 for ; Tue, 23 Mar 2021 21:25:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E30726198C for ; Tue, 23 Mar 2021 21:25:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233565AbhCWVZB (ORCPT ); Tue, 23 Mar 2021 17:25:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:48588 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233537AbhCWVYt (ORCPT ); Tue, 23 Mar 2021 17:24:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1616534688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tb9DUv24f1dUzGNk1qYsdtnBS4ySB3TMrZJ4ucwL8W8=; b=qM5m7Waw7Y9EHCNeAYU2ul6cqPAgZOviXnZlo8uDNTBHzqzME2HTod/Q7vLChPIrKaYtX5 pL26uqCevja2JirZT/6cwMUQ5Y2uxU6ZqVMd3uICxGI3d5skela2HptT7dzFPa/llYjix4 rvC/sZKtYF9wq8J+lgguePPOrUuAMLU= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DB816ACBF; Tue, 23 Mar 2021 21:24:47 +0000 (UTC) From: mwilck@suse.com To: "Martin K. Petersen" , Christoph Hellwig Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, David Disseldorp , =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= , Chaitanya Kulkarni , Martin Wilck Subject: [PATCH v2 2/2] target: pscsi: cleanup after failure in pscsi_map_sg() Date: Tue, 23 Mar 2021 22:24:31 +0100 Message-Id: <20210323212431.15306-2-mwilck@suse.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210323212431.15306-1-mwilck@suse.com> References: <20210323212431.15306-1-mwilck@suse.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Martin Wilck If pscsi_map_sg() fails, make sure to drop references to already allocated bios. Signed-off-by: Martin Wilck Reviewed-by: Christoph Hellwig Reviewed-by: Lee Duncan --- drivers/target/target_core_pscsi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 977362d..1c9aeab 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -937,6 +937,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, return 0; fail: + if (bio) + bio_put(bio); + while (req->bio) { + bio = req->bio; + req->bio = bio->bi_next; + bio_put(bio); + } + req->biotail = NULL; return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; }