From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shravan Kumar Ramani <shravankr@nvidia.com>
Cc: Vadim Pasternak <vadimp@nvidia.com>,
David Thompson <davthompson@nvidia.com>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
David Thompson <davthomspson@nvidia.com>
Subject: Re: [PATCH v2 1/2] platform/mellanox: mlxbf-pmc: Replace strcmp with strncmp
Date: Thu, 26 Jun 2025 18:50:07 +0300 (EEST) [thread overview]
Message-ID: <f8437991-2688-33f8-3843-4e5ffe72a308@linux.intel.com> (raw)
In-Reply-To: <fbb8ab5fd566369cc47e9f23b9f4ac25dde009b8.1750245955.git.shravankr@nvidia.com>
On Wed, 18 Jun 2025, Shravan Kumar Ramani wrote:
> Since the input string passed via the command line appends a newline char,
> comparison using strcmp is not correct. Use the string length of the
> event_list entries to match the string using strncmp instead.
Please include () after any function name (don't forget those in the
shortlog).
> Fixes: 1a218d312e65 ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver")
> Signed-off-by: Shravan Kumar Ramani <shravankr@nvidia.com>
> Reviewed-by: David Thompson <davthomspson@nvidia.com>
> ---
> drivers/platform/mellanox/mlxbf-pmc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
> index 900069eb186e..366c0cba447f 100644
> --- a/drivers/platform/mellanox/mlxbf-pmc.c
> +++ b/drivers/platform/mellanox/mlxbf-pmc.c
> @@ -1215,7 +1215,7 @@ static int mlxbf_pmc_get_event_num(const char *blk, const char *evt)
> return -EINVAL;
>
> for (i = 0; i < size; ++i) {
> - if (!strcmp(evt, events[i].evt_name))
> + if (!strncmp(evt, events[i].evt_name, strlen(events[i].evt_name)))
So if there's extra garbage behind the input, it will also match
spuriously? So store the len and reduce it if there's a trailing newline
to make it more robust?
> return events[i].evt_num;
> }
>
>
--
i.
next prev parent reply other threads:[~2025-06-26 15:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 11:39 [PATCH v2 0/2] Bug fixes to mlxbf-pmc Shravan Kumar Ramani
2025-06-18 11:39 ` [PATCH v2 1/2] platform/mellanox: mlxbf-pmc: Replace strcmp with strncmp Shravan Kumar Ramani
2025-06-26 15:50 ` Ilpo Järvinen [this message]
2025-06-18 11:39 ` [PATCH v2 2/2] platform/mellanox: mlxbf-pmc: Validate event/enable input Shravan Kumar Ramani
2025-06-26 15:35 ` Ilpo Järvinen
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=f8437991-2688-33f8-3843-4e5ffe72a308@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=davthompson@nvidia.com \
--cc=davthomspson@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=shravankr@nvidia.com \
--cc=vadimp@nvidia.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