* [PATCH v3] net: ethernet: emulex: benet: fix adapter->fw_on_flash truncation warning
@ 2025-10-24 18:15 Ankan Biswas
2025-10-29 1:42 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Ankan Biswas @ 2025-10-24 18:15 UTC (permalink / raw)
To: ajit.khaparde, sriharsha.basavapatna, somnath.kotur,
andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, skhan, khalid, david.hunter.linux,
linux-kernel-mentees, Ankan Biswas
The benet driver copies both fw_ver (32 bytes) and fw_on_flash (32 bytes)
into ethtool_drvinfo->fw_version (32 bytes), leading to a potential
string truncation warning when built with W=1.
Store fw_on_flash in ethtool_drvinfo->erom_version instead, which some
drivers use to report secondary firmware information.
Signed-off-by: Ankan Biswas <spyjetfayed@gmail.com>
---
drivers/net/ethernet/emulex/benet/be_ethtool.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index f9216326bdfe..752f838f1abf 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -221,12 +221,20 @@ static void be_get_drvinfo(struct net_device *netdev,
struct be_adapter *adapter = netdev_priv(netdev);
strscpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
- if (!memcmp(adapter->fw_ver, adapter->fw_on_flash, FW_VER_LEN))
+ if (!memcmp(adapter->fw_ver, adapter->fw_on_flash, FW_VER_LEN)) {
strscpy(drvinfo->fw_version, adapter->fw_ver,
sizeof(drvinfo->fw_version));
- else
- snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
- "%s [%s]", adapter->fw_ver, adapter->fw_on_flash);
+
+ } else {
+ strscpy(drvinfo->fw_version, adapter->fw_ver,
+ sizeof(drvinfo->fw_version));
+
+ /*
+ * Report fw_on_flash in ethtool's erom_version field.
+ */
+ strscpy(drvinfo->erom_version, adapter->fw_on_flash,
+ sizeof(drvinfo->erom_version));
+ }
strscpy(drvinfo->bus_info, pci_name(adapter->pdev),
sizeof(drvinfo->bus_info));
--
2.51.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] net: ethernet: emulex: benet: fix adapter->fw_on_flash truncation warning
2025-10-24 18:15 [PATCH v3] net: ethernet: emulex: benet: fix adapter->fw_on_flash truncation warning Ankan Biswas
@ 2025-10-29 1:42 ` Jakub Kicinski
2025-10-29 7:00 ` Ankan Biswas
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2025-10-29 1:42 UTC (permalink / raw)
To: Ankan Biswas
Cc: ajit.khaparde, sriharsha.basavapatna, somnath.kotur,
andrew+netdev, davem, edumazet, pabeni, netdev, linux-kernel,
skhan, khalid, david.hunter.linux, linux-kernel-mentees
On Fri, 24 Oct 2025 23:45:41 +0530 Ankan Biswas wrote:
> The benet driver copies both fw_ver (32 bytes) and fw_on_flash (32 bytes)
> into ethtool_drvinfo->fw_version (32 bytes), leading to a potential
> string truncation warning when built with W=1.
>
> Store fw_on_flash in ethtool_drvinfo->erom_version instead, which some
> drivers use to report secondary firmware information.
You are changing user-visible behavior to silence a W=1 warning.
I can't stress enough how bad of an idea this is.
Please find a better fix.. or leave this code be.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] net: ethernet: emulex: benet: fix adapter->fw_on_flash truncation warning
2025-10-29 1:42 ` Jakub Kicinski
@ 2025-10-29 7:00 ` Ankan Biswas
0 siblings, 0 replies; 3+ messages in thread
From: Ankan Biswas @ 2025-10-29 7:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: ajit.khaparde, sriharsha.basavapatna, somnath.kotur,
andrew+netdev, davem, edumazet, pabeni, netdev, linux-kernel,
skhan, khalid, david.hunter.linux, linux-kernel-mentees
On 10/29/25 7:12 AM, Jakub Kicinski wrote:
> On Fri, 24 Oct 2025 23:45:41 +0530 Ankan Biswas wrote:
>> The benet driver copies both fw_ver (32 bytes) and fw_on_flash (32 bytes)
>> into ethtool_drvinfo->fw_version (32 bytes), leading to a potential
>> string truncation warning when built with W=1.
>>
>> Store fw_on_flash in ethtool_drvinfo->erom_version instead, which some
>> drivers use to report secondary firmware information.
>
> You are changing user-visible behavior to silence a W=1 warning.
> I can't stress enough how bad of an idea this is.
> Please find a better fix.. or leave this code be.
Hi Jakub,
Thanks for the feedback. I felt this would be better than the value
appearing truncated to the user. However, yes this is not the ideal fix.
Will avoid modifying user-visible behavior.
An ideal fix may require a lot more changes, which may not be worth the
effort at this point, so I guess it is better to drop this patch.
Best Regards,
Ankan Biswas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-29 7:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 18:15 [PATCH v3] net: ethernet: emulex: benet: fix adapter->fw_on_flash truncation warning Ankan Biswas
2025-10-29 1:42 ` Jakub Kicinski
2025-10-29 7:00 ` Ankan Biswas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).