* [PATCH net-next] net/mlx5: Use kasprintf()
@ 2024-02-10 10:53 Christophe JAILLET
2024-02-20 7:57 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-02-10 10:53 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Or Gerlitz, Eli Cohen
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev,
linux-rdma
Use kasprintf() instead of open-coding it.
This saves some lines of code, avoid a hard-coded magic number and is more
robust.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
If you consider it as a bug fix, should 'name' overflow because of the
hard-coded limit, then:
Fixes: ac6ea6e81a80 ("net/mlx5_core: Use private health thread for each device")
---
drivers/net/ethernet/mellanox/mlx5/core/health.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 8ff6dc9bc803..3f775da15afc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -856,12 +856,11 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
mlx5_reporter_vnic_create(dev);
health = &dev->priv.health;
- name = kmalloc(64, GFP_KERNEL);
+ name = kasprintf(GFP_KERNEL,
+ "mlx5_health%s", dev_name(dev->device));
if (!name)
goto out_err;
- strcpy(name, "mlx5_health");
- strcat(name, dev_name(dev->device));
health->wq = create_singlethread_workqueue(name);
kfree(name);
if (!health->wq)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net/mlx5: Use kasprintf()
2024-02-10 10:53 [PATCH net-next] net/mlx5: Use kasprintf() Christophe JAILLET
@ 2024-02-20 7:57 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2024-02-20 7:57 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Or Gerlitz, Eli Cohen, linux-kernel,
kernel-janitors, netdev, linux-rdma
On Sat, Feb 10, 2024 at 11:53:13AM +0100, Christophe JAILLET wrote:
> Use kasprintf() instead of open-coding it.
> This saves some lines of code, avoid a hard-coded magic number and is more
> robust.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> If you consider it as a bug fix, should 'name' overflow because of the
> hard-coded limit, then:
> Fixes: ac6ea6e81a80 ("net/mlx5_core: Use private health thread for each device")
TBH I am entirely unsure if an overflow can occur.
But in any case the change looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-20 7:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-10 10:53 [PATCH net-next] net/mlx5: Use kasprintf() Christophe JAILLET
2024-02-20 7:57 ` Simon Horman
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).