From: Dan Carpenter <dan.carpenter@linaro.org>
To: Karan Tilak Kumar <kartilak@cisco.com>
Cc: sebaddel@cisco.com, arulponn@cisco.com, djhawar@cisco.com,
gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com,
aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
Date: Tue, 7 Jan 2025 15:30:05 +0300 [thread overview]
Message-ID: <4141c9ab-c640-4765-a23c-c2f64df687cb@stanley.mountain> (raw)
In-Reply-To: <20241212020312.4786-8-kartilak@cisco.com>
On Wed, Dec 11, 2024 at 06:03:04PM -0800, Karan Tilak Kumar wrote:
> @@ -612,6 +615,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> unsigned long flags;
> int hwq;
> char *desc, *subsys_desc;
> + int len;
Do not introduce unnecessary levels of indirection. Get rid of this len
variable.
>
> /*
> * Allocate SCSI Host and set up association between host,
> @@ -646,9 +650,17 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> fnic_stats_debugfs_init(fnic);
>
> /* Find model name from PCIe subsys ID */
> - if (fnic_get_desc_by_devid(pdev, &desc, &subsys_desc) == 0)
> + if (fnic_get_desc_by_devid(pdev, &desc, &subsys_desc) == 0) {
> dev_info(&fnic->pdev->dev, "Model: %s\n", subsys_desc);
> - else {
> +
> + /* Update FDMI model */
This comment adds no information. Delete it.
> + fnic->subsys_desc_len = strlen(subsys_desc);
Keep in mind that strlen() does not count the NUL-terminator.
> + len = ARRAY_SIZE(fnic->subsys_desc);
Use sizeof() when you are talking about bytes or chars. For snprintf() and
other string functions, it's always sizeof() and never ARRAY_SIZE().
> + if (fnic->subsys_desc_len > len)
> + fnic->subsys_desc_len = len;
> + memcpy(fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len);
So this is an 0-14 character buffer. If fnic->subsys_desc_len is set to 14,
then the string is not NUL terminated. This is how the buffer is used in
fdls_fdmi_register_hba()
strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN);
data[FNIC_FDMI_MODEL_LEN - 1] = 0;
This suggests that fnic->subsys_desc is expected to be NUL-terminated.
However FNIC_FDMI_MODEL_LEN is 12. So in that case the last 3 characters
are removed. LOL. It's harmless but so very annoying.
Also strscpy_pad() will ensure that data[FNIC_FDMI_MODEL_LEN - 1] is set
to zero so that line could be deleted.
regards,
dan carpenter
next prev parent reply other threads:[~2025-01-07 12:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 2:02 [PATCH v7 00/15] Introduce support for Fabric Discovery and Karan Tilak Kumar
2024-12-12 2:02 ` [PATCH v7 01/15] scsi: fnic: Replace shost_printk with dev_info/dev_err Karan Tilak Kumar
2024-12-12 2:02 ` [PATCH v7 02/15] scsi: fnic: Add headers and definitions for FDLS Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 03/15] scsi: fnic: Add support for fabric based solicited requests and responses Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 04/15] scsi: fnic: Add support for target " Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 05/15] scsi: fnic: Add support for unsolicited " Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 06/15] scsi: fnic: Add Cisco hardware model names Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI Karan Tilak Kumar
2025-01-07 12:30 ` Dan Carpenter [this message]
2025-01-08 21:47 ` Karan Tilak Kumar (kartilak)
2025-01-13 17:35 ` John Meneghini
2025-01-13 20:28 ` Karan Tilak Kumar (kartilak)
2025-01-14 9:59 ` Dan Carpenter
2025-01-14 15:15 ` John Meneghini
2025-01-15 1:03 ` Karan Tilak Kumar (kartilak)
2025-01-16 6:29 ` Dan Carpenter
2024-12-12 2:03 ` [PATCH v7 08/15] scsi: fnic: Add and integrate support for FIP Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 09/15] scsi: fnic: Add functionality in fnic to support FDLS Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 10/15] scsi: fnic: Modify IO path to use FDLS Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 11/15] scsi: fnic: Modify fnic interfaces " Karan Tilak Kumar
2025-01-07 13:18 ` Dan Carpenter
2025-01-08 21:40 ` Karan Tilak Kumar (kartilak)
2025-01-09 8:23 ` Dan Carpenter
2025-01-10 9:37 ` Karan Tilak Kumar (kartilak)
2024-12-12 2:03 ` [PATCH v7 12/15] scsi: fnic: Add stats and related functionality Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 13/15] scsi: fnic: Code cleanup Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 14/15] scsi: fnic: Add support to handle port channel RSCN Karan Tilak Kumar
2024-12-12 2:03 ` [PATCH v7 15/15] scsi: fnic: Increment driver version Karan Tilak Kumar
2025-01-02 21:09 ` [PATCH v7 00/15] Introduce support for Fabric Discovery and Martin K. Petersen
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=4141c9ab-c640-4765-a23c-c2f64df687cb@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=aeasi@cisco.com \
--cc=arulponn@cisco.com \
--cc=djhawar@cisco.com \
--cc=gcboffa@cisco.com \
--cc=jejb@linux.ibm.com \
--cc=kartilak@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lkp@intel.com \
--cc=martin.petersen@oracle.com \
--cc=mkai2@cisco.com \
--cc=satishkh@cisco.com \
--cc=sebaddel@cisco.com \
/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
all inboxes | Powered by JetHome®