1
1

realtek: kzalloc + kcalloc to kzalloc

Use a flexible array member to combine allocations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/22651
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This commit is contained in:
Rosen Penev 2026-04-07 15:03:42 -07:00 committed by Jonas Jelonek
parent 383c4469e4
commit a302626ef4
No known key found for this signature in database
2 changed files with 10 additions and 13 deletions

View File

@ -1560,6 +1560,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
{
struct rtl838x_switch_priv *priv;
struct device *dev = &pdev->dev;
const struct rtldsa_config *r;
u64 bpdu_mask;
int err = 0;
@ -1579,11 +1580,12 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
/* Initialize access to RTL switch tables */
rtl_table_init();
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
r = device_get_match_data(&pdev->dev);
priv = devm_kzalloc(dev, struct_size(priv, msts, r->n_mst - 1), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->r = device_get_match_data(&pdev->dev);
priv->r = r;
priv->ds = devm_kzalloc(dev, sizeof(*priv->ds), GFP_KERNEL);
if (!priv->ds)
@ -1620,12 +1622,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
return err;
}
priv->msts = devm_kcalloc(priv->dev,
priv->r->n_mst - 1, sizeof(struct rtldsa_mst),
GFP_KERNEL);
if (!priv->msts)
return -ENOMEM;
priv->wq = create_singlethread_workqueue("rtl83xx");
if (!priv->wq) {
dev_err(dev, "Error creating workqueue: %d\n", err);

View File

@ -1555,11 +1555,6 @@ struct rtl838x_switch_priv {
u16 intf_mtus[MAX_INTF_MTUS];
int intf_mtu_count[MAX_INTF_MTUS];
/**
* @msts: MSTI to HW MST slot allocations. index 0 is for HW slot 1 because CIST is
* not stored in @msts
*/
struct rtldsa_mst *msts;
struct delayed_work counters_work;
/**
@ -1568,6 +1563,12 @@ struct rtl838x_switch_priv {
* periodically.
*/
struct mutex counters_lock;
/**
* @msts: MSTI to HW MST slot allocations. index 0 is for HW slot 1 because CIST is
* not stored in @msts
*/
struct rtldsa_mst msts[];
};
struct fdb_update_work {