From: sashiko-bot@kernel.org
To: "Karan Tilak Kumar" <kartilak@cisco.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 03/13] scsi: fnic: Decode firmware role configuration
Date: Fri, 24 Jul 2026 18:07:01 +0000 [thread overview]
Message-ID: <20260724180702.22B711F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724174811.5118-4-kartilak@cisco.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Probing a device configured as an NVMe initiator causes guaranteed NULL/invalid pointer dereferences because `fnic->host` is never allocated.
--
--- Patch [3]: [PATCH v6 03/13] scsi: fnic: Decode firmware role configuration ---
commit 59ee4f0111b49617d84eeb07cca8bec4e3b8d757
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Decode firmware role configuration
This commit adds FNIC_ROLE_CONFIG_MASK to decode firmware role bits when
reading vNIC configuration. It accepts FCP and NVMe initiator roles,
reports target roles as unsupported, and logs the configured role flags.
> diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
> index 7c7f9ea5267b9..3a365ea455b1a 100644
> --- a/drivers/scsi/fnic/fnic_main.c
> +++ b/drivers/scsi/fnic/fnic_main.c
[ ... ]
> @@ -863,8 +863,27 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> fnic->fnic_num);
> }
> break;
> + case VFCF_FC_TARGET:
> + dev_info(&fnic->pdev->dev,
> + "fnic: %d is scsi target\n",
> + fnic->fnic_num);
> + err = -EOPNOTSUPP;
> + goto err_out_fnic_role;
> + case VFCF_FC_NVME_INITIATOR:
> + fnic->role = FNIC_ROLE_NVME_INITIATOR;
> + dev_info(&fnic->pdev->dev, "fnic: %d is NVME initiator\n",
> + fnic->fnic_num);
> + break;
[Severity: High]
If a device is configured as an NVMe initiator, this case breaks out of the
switch block without allocating fnic->host (unlike the VFCF_FC_INITIATOR
case). Could this cause a NULL pointer dereference later on?
For example, if an error occurs shortly after this in fnic_probe(), the
teardown path unconditionally calls:
err_out_fnic_set_intr_mode:
scsi_host_put(fnic->host);
Since scsi_host_put() resolves the host pointer internally, passing NULL
results in an invalid offset pointer passed to put_device(), crashing the
kernel.
Additionally, does the success path unconditionally dereference the
unallocated host in fnic_scsi_drv_init()?
fnic_probe() -> fnic_scsi_drv_init() {
...
if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD)
host->can_queue = min_t(u32, FNIC_MAX_IO_REQ, ...);
...
}
> + case VFCF_FC_NVME_TARGET:
> + dev_info(&fnic->pdev->dev,
> + "fnic: %d is NVME target\n",
> + fnic->fnic_num);
> + err = -EOPNOTSUPP;
> + goto err_out_fnic_role;
> default:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724174811.5118-1-kartilak@cisco.com?part=3
next prev parent reply other threads:[~2026-07-24 18:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 17:47 [PATCH v6 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
2026-07-24 17:47 ` [PATCH v6 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
2026-07-24 18:16 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
2026-07-24 18:09 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 03/13] scsi: fnic: Decode firmware role configuration Karan Tilak Kumar
2026-07-24 18:07 ` sashiko-bot [this message]
2026-07-24 17:48 ` [PATCH v6 04/13] scsi: fnic: Advertise NVMe initiator service parameters Karan Tilak Kumar
2026-07-24 18:05 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
2026-07-24 18:54 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
2026-07-24 18:20 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
2026-07-24 18:26 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 08/13] scsi: fnic: Handle NVMe LS frames in FDLS Karan Tilak Kumar
2026-07-24 18:17 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
2026-07-24 18:16 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
2026-07-24 18:26 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
2026-07-24 18:31 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
2026-07-24 18:25 ` sashiko-bot
2026-07-24 17:48 ` [PATCH v6 13/13] scsi: fnic: Bump up version number Karan Tilak Kumar
2026-07-24 18:18 ` sashiko-bot
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=20260724180702.22B711F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kartilak@cisco.com \
--cc=linux-scsi@vger.kernel.org \
--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