From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: Sunil Goutham <sgoutham@marvell.com>,
Linu Cherian <lcherian@marvell.com>,
Geetha sowjanya <gakula@marvell.com>,
hariprasad <hkelam@marvell.com>,
Subbaraya Sundeep <sbhatta@marvell.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net-next] octeontx2-af: CGX: use kzalloc_flex for name
Date: Thu, 12 Mar 2026 17:32:40 -0700 [thread overview]
Message-ID: <20260313003240.123975-1-rosenp@gmail.com> (raw)
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
next reply other threads:[~2026-03-13 0:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 0:32 Rosen Penev [this message]
2026-03-13 20:31 ` [PATCH net-next] octeontx2-af: CGX: use kzalloc_flex for name Joe Damato
2026-03-14 15:46 ` Jakub Kicinski
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=20260313003240.123975-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=kuba@kernel.org \
--cc=lcherian@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.