diff mbox series

[1/3,v4] wifi: mwifiex: prefer strscpy() over strlcpy()

Message ID 20230629085115.180499-1-dmantipov@yandex.ru
State New
Headers show
Series [1/3,v4] wifi: mwifiex: prefer strscpy() over strlcpy() | expand

Commit Message

Dmitry Antipov June 29, 2023, 8:51 a.m. UTC
Prefer 'strscpy()' over 'strlcpy()' in 'mwifiex_init_hw_fw()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v4: simplify to drop strlcpy() only (Brian Norris)
---
 drivers/net/wireless/marvell/mwifiex/main.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Brian Norris June 29, 2023, 7:52 p.m. UTC | #1
On Thu, Jun 29, 2023 at 11:51:01AM +0300, Dmitry Antipov wrote:
[...]
> This also fixes an improper usage of 'sizeof()'. Since 'skb' is
> extended with 'sizeof(mgmt->u.action.u.tdls_discover_resp) + 1'
> bytes (where 1 is actually 'sizeof(mgmt->u.action.category)'),
> I assume that the same number of bytes should be copied.
> 
> Suggested-by: Brian Norris <briannorris@chromium.org>

I don't believe I actually *suggested* the change; I just highlighted
that the size looked sketchy in the original code. :)

But your change does look correct, and I don't see how we could possibly
*want* to be off by 1 here, so:

Reviewed-by: Brian Norris <briannorris@chromium.org>

> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> v4: fix memmove() size calculation (Brian Norris)
> ---
>  drivers/net/wireless/marvell/mwifiex/tdls.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
Kalle Valo July 25, 2023, 3:14 p.m. UTC | #2
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Prefer 'strscpy()' over 'strlcpy()' in 'mwifiex_init_hw_fw()'.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> Reviewed-by: Brian Norris <briannorris@chromium.org>

2 patches applied to wireless-next.git, thanks.

caf9ead2c7d0 wifi: mwifiex: prefer strscpy() over strlcpy()
dcce94b80a95 wifi: mwifiex: fix fortify warning
diff mbox series

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index ea22a08e6c08..64512b00e8b5 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -724,14 +724,9 @@  static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter,
 	/* Override default firmware with manufacturing one if
 	 * manufacturing mode is enabled
 	 */
-	if (mfg_mode) {
-		if (strlcpy(adapter->fw_name, MFG_FIRMWARE,
-			    sizeof(adapter->fw_name)) >=
-			    sizeof(adapter->fw_name)) {
-			pr_err("%s: fw_name too long!\n", __func__);
-			return -1;
-		}
-	}
+	if (mfg_mode)
+		strscpy(adapter->fw_name, MFG_FIRMWARE,
+			sizeof(adapter->fw_name));
 
 	if (req_fw_nowait) {
 		ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name,