From patchwork Mon May 6 12:38:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongzhi Liu X-Patchwork-Id: 795676 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F2CA6D1AE; Mon, 6 May 2024 12:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714999134; cv=none; b=XxsNdyjfu9cLnk4DZ18i2Kzb4mL4/O/Ek+WRCVQXiW0VtJL1p07Y8lLw4RB+lR46zdrjx0YE7w3hcL7EKCO17tQpCq8EtjotcIOWi83NiN6YfKCPk4FO+K2FGozzzmfMjObCNMGixeIU8LsQc6C3nBOXm/N0posKZRyvumPFajA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714999134; c=relaxed/simple; bh=sPTIC6nV8SFxWIhmUEK7axZd9dNmSKGsvS59vAVuZrg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KNUeoIySHPNjOxUTXf4kj6sL9QvjH52gQxmS8wz5DiCl+u83srlz7oOSfXL6zUgpetdyTTedYmbGdNaQol+gIjFgsBgHEQHMR8kx+U2GcJyA1i5riLcERHymINrcPfN8WoO6ISoC0j/MClLeB6TndXLPkCoMcnAxehTf+dL+8iY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A+W34BYK; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A+W34BYK" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6f460e05101so989518b3a.1; Mon, 06 May 2024 05:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714999133; x=1715603933; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ogvRpvfHRpVd7OHXkJkp6+RPq3FZxpMxszDa78eRG34=; b=A+W34BYK4e7iU9781W65Fb6UoZ1avD8T4E603ZC7J1/a4P/1gbtdVgdddPwjjsqwgG B5iWR6jfeWwzbK5maBL0ccMSAE3fW08Vjzaw4IfY9UHj0Sks+EYGJ2yHPFTym1y7/gCf 3k0wTDAORxvYtLUKalJzp0AqkdfZDxK6us8hWmjVVBAU2iNQuWvkKPRmtDEWXF3V5ptK vshgX8hi0D5W3rcjji7Fya2tieO+eLRNovCweesD4mx2Dg57IykvvXQpeMYubARMxcmJ o/ieVEQuilhVgPVjEF4WbnYOSxuIkEBWmjVxk4yss3JSN3AMgdj6KnnLog3+XJgPIhIp l4vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714999133; x=1715603933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ogvRpvfHRpVd7OHXkJkp6+RPq3FZxpMxszDa78eRG34=; b=VPjNlE8fnXqHw29eYV8DqNRVr4wq/27MGgeDfiNXtANFH0qOHPxvx0vc+iOO//8vsV 1arDM8EqSr2V0fQ+GUfcKWsAq83UaBHqxLO0YLe9eE3zMt2XaFPbC+D5NTWUv6MZV0J6 WBZn0Od1z8oRjpezGxOLHw3xv2wtm/mfPbHNIB2r/tLpVFRBIL6GN6/p2gyTD1zuQ/6x irg2+K8q2WaemSQzdkdX8/BNc3w4Eqd8yJgKdsFfB0zJvdLtBfFyUHo3BW8m7l4cR2Qk UUaoYHvpRAusre8CdhBdC153H02V9bP5rTgh9EoLwPiU4dVo484AP17zUH2oyufjLDOJ Nw4w== X-Forwarded-Encrypted: i=1; AJvYcCU1Ye+4E1CzeRle4RGnGmSAa86/1aD45h4Yo6/d4hffrgOxi1808wzkL1aloAydbErb8b4GOY1m/WOEZPnyLg9WAhYrOALDJjw2iWVSRolvdcDP7jJ2WDEKyvXJOeBQPX2Ra2FR/Tk2xg== X-Gm-Message-State: AOJu0YzEWvTfzogC1uBmvG7Sli3YGAhGAMXlsk4rVA2fQkSZx8qiMSZM H8H3GQitSwHQRrljZsG3NnzdyvTNAMu7ngn3mIoENzQuzSyM8vtu X-Google-Smtp-Source: AGHT+IEx3fb+7CZAdI2HFwkeSLYJo/LvRwcZTbPcVmho9H+x5RnGiZdks67LuE4ECCLmjLmlv5lePQ== X-Received: by 2002:a05:6a20:72a0:b0:1af:ab23:82ce with SMTP id o32-20020a056a2072a000b001afab2382cemr6275075pzk.3.1714999132652; Mon, 06 May 2024 05:38:52 -0700 (PDT) Received: from VM-147-239-centos.localdomain ([43.132.141.4]) by smtp.gmail.com with ESMTPSA id w6-20020a634746000000b005dc4829d0e1sm7940433pgk.85.2024.05.06.05.38.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2024 05:38:52 -0700 (PDT) From: Yongzhi Liu To: skashyap@marvell.com, Markus.Elfring@web.de, njavali@marvell.com, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com Cc: himanshu.madhani@oracle.com, GR-QLogic-Storage-Upstream@marvell.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, jitxie@tencent.com, huntazhang@tencent.com, Yongzhi Liu Subject: [PATCH V4 1/2] scsi: qla2xxx: Fix double free of fcport in qla24xx_els_dcmd_iocb() Date: Mon, 6 May 2024 20:38:34 +0800 Message-Id: <20240506123835.17527-2-hyperlyzcs@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20240506123835.17527-1-hyperlyzcs@gmail.com> References: <230af978-c834-423b-8d42-78c164be40b9@web.de> <20240506123835.17527-1-hyperlyzcs@gmail.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When dma_alloc_coherent() or qla2x00_start_sp() returned an error, the callback function qla2x00_els_dcmd_sp_free in qla2x00_sp_release called qla2x00_free_fcport() to free "fcport". We shouldn't call qla2x00_free_fcport() again in the error handling paths, and thus delete the duplicate qla2x00_free_fcport() calls. Fixes: 82f522ae0d97 ("scsi: qla2xxx: Fix double free of fcport") Signed-off-by: Yongzhi Liu --- drivers/scsi/qla2xxx/qla_iocb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 0b41e8a06602..faec66bd1951 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2751,7 +2751,6 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, if (!elsio->u.els_logo.els_logo_pyld) { /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); - qla2x00_free_fcport(fcport); return QLA_FUNCTION_FAILED; } @@ -2776,7 +2775,6 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, if (rval != QLA_SUCCESS) { /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); - qla2x00_free_fcport(fcport); return QLA_FUNCTION_FAILED; } From patchwork Mon May 6 12:38:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongzhi Liu X-Patchwork-Id: 795145 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47888335B5; Mon, 6 May 2024 12:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714999143; cv=none; b=T8DYVeixdjZx6tFdlL4GIrwuTa74spWa5Y+cZZQylzScgvltjMhMMSSI/tqWbdW8Y6Glju5qVZjdRmpK+EooVnvkF5pAhBcRgHKDINQg0GuAWZ+HGQDDVDTvdRULq/oElOcVwtZbvGlMbmoe7NAj27/y8XBfz4PqatITMNxsn1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714999143; c=relaxed/simple; bh=3Xlpqb/h/LbWUA++nfPRA220rLCTMZ3RCe9XHjr+l7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hxLk2APawU0vJ67ictwAAbDVhgDBw5CjUMFrti7Y4yIFEniuQHCMXCJtgcMI1c39QDrkfhmRufTbyxINzdVG2cORTn424q8xEEE3ReiheAaZsq2wuvm78GDhpnS2LB05B/rqYfosyaxzfELqqhyCHvkkki0A87UEzjq6A9r5vk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gGSN35JL; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gGSN35JL" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6f44bcbaae7so1398483b3a.2; Mon, 06 May 2024 05:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714999141; x=1715603941; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Hkuj0HKDvuaVZat/vZwkf1H5ug1+hqs2t9w9FcU+/I=; b=gGSN35JLsPNH1XqkPHO8i3MeEdILygGEEuyn8wn7QiJhCfbZe2iPBxy4amaBQKM2FG UMLJrVmLraB5eH5xSSywDedEtcR/Tu9umhmvhPys1pikPFNTN3474gyyeKr+clIqmXmB Kvml3jvMkMQKsLx5wz2IstzNDujSYbMJcz5Sdnmsu1E8O9JXG+nMUFmrgbZmGnnKx/d2 fy4E/pwGIDp40FLxW+7ULFP66fYGMLplkkuyqbCUlrOW0fyFgviNgJpo4hDnHpHK70G9 E9M7fTmhu8Pb0Rn0S/XCfg+9+7gnWdzdynFAJ3jPtU5fyO1h515HDiRGPkzlWN2ZpmEz vi8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714999141; x=1715603941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Hkuj0HKDvuaVZat/vZwkf1H5ug1+hqs2t9w9FcU+/I=; b=fbb6eoqf2I9YsjeEj8b6pnyKDA1L/d4A++wPSj/xIgqSAL/TMq+Z3Nu7VYWEw3PPtX drdqISv5xiWsudK1o8dIA+dhg9vL7w5JT/Dn1m5OG0BRQn51Dh24O0yO3Jta2UGaZ7db 5paxRWHT6bAkZlUxl0+aie84OZbgm1EO9n1zrc+R1kOdj3ypnh5SCrD8GzCFlFRioYQq ZhSJOzNd0wdX31lScsZj0cdQFYSKRzhNdCJJyKwgnm4DTiFJrROTDXEJA9o92OsR/TA/ cwqULPQeT87+Y/B6bx5SDMsH0QBW3uFqd7bFJa6UREBKzWE1hAaAbX9QheKfELKSwrJE Ab8Q== X-Forwarded-Encrypted: i=1; AJvYcCUoJui2aAObA+IszgDNHSYy3f80Qgk+GJWmq98MF4KCTPbEHfPC1/29HTxxuN4yN7FNwhf2lEt/5sbP3yFLl2QFnAbIpxs8gXFBEm7QZ4QYswjUua7rjlj+kjSTYE39jbo00lVqCkVswQ== X-Gm-Message-State: AOJu0YxxafMtjWpQNXz/uZdcbxzF0gTWfo6l3xkC+rL6zAhFbrOm33bl u2bDWIWRJF71kElf6QtuKN/JuzDNfoq2yQEhmVM3tVtUZOLddmYp X-Google-Smtp-Source: AGHT+IFkngSnVvSFrcNDs7AF9Vc61JHe4VaYwZt/7TDSFo4ybVjBShyMNDwQ4zSEqBkv3eixDs/flw== X-Received: by 2002:a05:6a00:93a4:b0:6ec:fd67:a27e with SMTP id ka36-20020a056a0093a400b006ecfd67a27emr10838652pfb.1.1714999141374; Mon, 06 May 2024 05:39:01 -0700 (PDT) Received: from VM-147-239-centos.localdomain ([43.132.141.4]) by smtp.gmail.com with ESMTPSA id w6-20020a634746000000b005dc4829d0e1sm7940433pgk.85.2024.05.06.05.38.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2024 05:39:00 -0700 (PDT) From: Yongzhi Liu To: skashyap@marvell.com, Markus.Elfring@web.de, njavali@marvell.com, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com Cc: himanshu.madhani@oracle.com, GR-QLogic-Storage-Upstream@marvell.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, jitxie@tencent.com, huntazhang@tencent.com, Yongzhi Liu Subject: [PATCH V4 2/2] scsi: qla2xxx: Use common error handling code in qla24xx_els_dcmd_iocb() Date: Mon, 6 May 2024 20:38:35 +0800 Message-Id: <20240506123835.17527-3-hyperlyzcs@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20240506123835.17527-1-hyperlyzcs@gmail.com> References: <230af978-c834-423b-8d42-78c164be40b9@web.de> <20240506123835.17527-1-hyperlyzcs@gmail.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a jump target so that a bit of exception handling can be better reused at the end of this function implementation. Signed-off-by: Yongzhi Liu Suggested-by: Markus Elfring --- drivers/scsi/qla2xxx/qla_iocb.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index faec66bd1951..a3a3904cbb47 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2749,9 +2749,8 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, GFP_KERNEL); if (!elsio->u.els_logo.els_logo_pyld) { - /* ref: INIT */ - kref_put(&sp->cmd_kref, qla2x00_sp_release); - return QLA_FUNCTION_FAILED; + rval = QLA_FUNCTION_FAILED; + goto put_ref; } memset(&logo_pyld, 0, sizeof(struct els_logo_payload)); @@ -2773,9 +2772,8 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, rval = qla2x00_start_sp(sp); if (rval != QLA_SUCCESS) { - /* ref: INIT */ - kref_put(&sp->cmd_kref, qla2x00_sp_release); - return QLA_FUNCTION_FAILED; + rval = QLA_FUNCTION_FAILED; + goto put_ref; } ql_dbg(ql_dbg_io, vha, 0x3074, @@ -2784,7 +2782,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, fcport->d_id.b.area, fcport->d_id.b.al_pa); wait_for_completion(&elsio->u.els_logo.comp); - +put_ref: /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); return rval;