From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 08/14] scsi: qla2xxx: Add validation check for base vport index during delete
Date: Wed, 21 Oct 2026 10:43:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-180114@kernel.org> (raw)
In-Reply-To: <20261021102310.3854868-9-njavali@marvell.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: qla2xxx: qla24xx_vport_delete() returns 0 on invalid vp_idx error
--
commit aea6ddb54a72c0125eb9b7df256e6e4ec1eed447
Author: Manish Rangankar <mrangankar@marvell.com>
scsi: qla2xxx: Add validation check for base vport index during delete
This commit adds a check in qla24xx_vport_delete() to log an error and return
early if vha->vp_idx is zero.
> diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
> index a4ca22024edeb..e6fc47c3f87f8 100644
> --- a/drivers/scsi/qla2xxx/qla_attr.c
> +++ b/drivers/scsi/qla2xxx/qla_attr.c
> @@ -3276,6 +3276,12 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
> struct qla_hw_data *ha = vha->hw;
> uint16_t id = vha->vp_idx;
>
> + if (!vha->vp_idx) {
> + ql_log(ql_log_fatal, vha, 0x700f,
> + "failed to delete Vport idx [%d]\n", vha->vp_idx);
> + return 0;
> + }
[Severity: High]
Should qla24xx_vport_delete() in drivers/scsi/qla2xxx/qla_attr.c return a
non-zero error code here instead of 0 when !vha->vp_idx?
qla24xx_vport_delete() is the .vport_delete callback invoked by
fc_vport_terminate() in drivers/scsi/scsi_transport_fc.c:
if (i->f->vport_delete)
stat = i->f->vport_delete(vport);
else
stat = -ENOENT;
spin_lock_irqsave(shost->host_lock, flags);
vport->flags &= ~FC_VPORT_DELETING;
if (!stat) {
vport->flags |= FC_VPORT_DELETED;
list_del(&vport->peers);
fc_host->npiv_vports_inuse--;
scsi_host_put(shost); /* for fc_host->vport list */
}
spin_unlock_irqrestore(shost->host_lock, flags);
if (stat)
return stat;
...
device_del(dev);
transport_destroy_device(dev);
put_device(dev); /* for self-reference */
When qla24xx_vport_delete() returns 0, fc_vport_terminate() treats the
deletion as successful and unregisters and frees struct fc_vport, even though
qla24xx_vport_delete() skipped tearing down vha, removing vha->host, stopping
the vport timer, freeing vha->gnl.l and vha->scan.l, removing vha from
ha->vp_list in qla24xx_deallocate_vp_id(), and decrementing
ha->cur_vport_count.
Does this leave vha active on ha->vp_list with a dangling vha->fc_vport
pointer, and cause qla2x00_delete_all_vps() in drivers/scsi/qla2xxx/qla_os.c
to loop infinitely on the freed vha->fc_vport during driver unload:
while (ha->cur_vport_count) {
spin_lock_irqsave(&ha->vport_slock, flags);
BUG_ON(base_vha->list.next == &ha->vp_list);
/* This assumes first entry in ha->vp_list is always base vha */
vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list);
scsi_host_get(vha->host);
spin_unlock_irqrestore(&ha->vport_slock, flags);
mutex_unlock(&ha->vport_lock);
qla_nvme_delete(vha);
fc_vport_terminate(vha->fc_vport);
scsi_host_put(vha->host);
mutex_lock(&ha->vport_lock);
}
because vha is never removed from base_vha->list and ha->cur_vport_count is
never decremented?
> +
> set_bit(VPORT_DELETE, &vha->dpc_flags);
>
> while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261021102310.3854868-1-njavali@marvell.com?part=8
next prev parent reply other threads:[~2026-10-21 10:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 10:22 [PATCH 00/14] scsi: qla2xxx: Misc. Bug fixes Nilesh Javali
2026-10-21 10:22 ` [PATCH 01/14] scsi: qla2xxx: Update MAINTAINERS with new FC storage alias Nilesh Javali
2026-10-21 10:22 ` [PATCH 02/14] scsi: qla2xxx: Update few AENs for 29xx handling Nilesh Javali
2026-10-21 10:22 ` [PATCH 03/14] Revert "scsi: qla2xxx: Validate BSG request_len before reading vendor_cmd[]" Nilesh Javali
2026-10-21 10:39 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 04/14] scsi: qla2xxx: Wait for session deletion before full-login LIP Nilesh Javali
2026-10-21 10:23 ` [PATCH 05/14] scsi: qla2xxx: Fix double addition of fcport to gnl.fcport list Nilesh Javali
2026-10-21 10:43 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 06/14] scsi: qla2xxx: Fix scan state machine race and IRQ-unsafe sp_unmap Nilesh Javali
2026-10-21 10:39 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 07/14] scsi: qla2xxx: Skip vport DPC processing during vport deletion Nilesh Javali
2026-10-21 10:36 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 08/14] scsi: qla2xxx: Add validation check for base vport index during delete Nilesh Javali
2026-10-21 10:43 ` sashiko-bot [this message]
2026-10-21 10:23 ` [PATCH 09/14] scsi: qla2xxx: Validate vport before deletion Nilesh Javali
2026-10-21 10:23 ` [PATCH 10/14] scsi: qla2xxx: Fix use-after-free races during vport deletion Nilesh Javali
2026-10-21 10:40 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 11/14] scsi: qla2xxx: Re-acquire vport_slock and refresh tvp during vport DPC Nilesh Javali
2026-10-21 10:43 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 12/14] scsi: qla2xxx: Yield work_lock in fabric scan path Nilesh Javali
2026-10-21 10:37 ` sashiko-bot
2026-10-21 10:23 ` [PATCH 13/14] scsi: qla2xxx: Fix purex IOCB copy size on non-29xx adapters Nilesh Javali
2026-10-21 10:23 ` [PATCH 14/14] scsi: qla2xxx: Update version to 12.00.00.2610b1 Nilesh Javali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-180114@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=njavali@marvell.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox