public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] octeontx2-af: CGX: use kzalloc_flex for name
@ 2026-03-13  0:32 Rosen Penev
  2026-03-13 20:31 ` Joe Damato
  2026-03-14 15:46 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-03-13  0:32 UTC (permalink / raw)
  To: netdev
  Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, hariprasad,
	Subbaraya Sundeep, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, open list

Don't bother allocating separately. There's no good reason to do so for
a small string like this.

Remove name kfrees as a result.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c     | 13 +++----------
 .../net/ethernet/marvell/octeontx2/af/lmac_common.h |  2 +-
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index 4f33a816bc7a..0750fb696c90 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -1725,14 +1725,10 @@ static int cgx_lmac_init(struct cgx *cgx)
 		cgx->lmac_count = cgx->max_lmac_per_mac;

 	for (i = 0; i < cgx->lmac_count; i++) {
-		lmac = kzalloc_obj(struct lmac);
+		lmac = kzalloc_flex(struct lmac, name, sizeof("cgx_fwi_xxx_yyy"));
 		if (!lmac)
 			return -ENOMEM;
-		lmac->name = kcalloc(1, sizeof("cgx_fwi_xxx_yyy"), GFP_KERNEL);
-		if (!lmac->name) {
-			err = -ENOMEM;
-			goto err_lmac_free;
-		}
+
 		sprintf(lmac->name, "cgx_fwi_%u_%u", cgx->cgx_id, i);
 		if (cgx->mac_ops->non_contiguous_serdes_lane) {
 			lmac->lmac_id = __ffs64(lmac_list);
@@ -1750,7 +1746,7 @@ static int cgx_lmac_init(struct cgx *cgx)

 		err = rvu_alloc_bitmap(&lmac->mac_to_index_bmap);
 		if (err)
-			goto err_name_free;
+			goto err_lmac_free;

 		/* Reserve first entry for default MAC address */
 		set_bit(0, lmac->mac_to_index_bmap.bmap);
@@ -1798,8 +1794,6 @@ static int cgx_lmac_init(struct cgx *cgx)
 	rvu_free_bitmap(&lmac->rx_fc_pfvf_bmap);
 err_dmac_bmap_free:
 	rvu_free_bitmap(&lmac->mac_to_index_bmap);
-err_name_free:
-	kfree(lmac->name);
 err_lmac_free:
 	kfree(lmac);
 	return err;
@@ -1825,7 +1819,6 @@ static int cgx_lmac_exit(struct cgx *cgx)
 		rvu_free_bitmap(&lmac->mac_to_index_bmap);
 		rvu_free_bitmap(&lmac->rx_fc_pfvf_bmap);
 		rvu_free_bitmap(&lmac->tx_fc_pfvf_bmap);
-		kfree(lmac->name);
 		kfree(lmac);
 	}

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h b/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
index 6180e68e1765..21504327032d 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
@@ -46,7 +46,7 @@ struct lmac {
 	u8 lmac_id;
 	u8 lmac_type;
 	bool cmd_pend;
-	char *name;
+	char name[];
 };

 /* CGX & RPM has different feature set
--
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-14 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13  0:32 [PATCH net-next] octeontx2-af: CGX: use kzalloc_flex for name Rosen Penev
2026-03-13 20:31 ` Joe Damato
2026-03-14 15:46 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox