lkml.org 
[lkml]   [2022]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC Patch net-next v2 5/9] net: dsa: microchip: move struct mib_names to ksz_chip_data
On Fri, May 13, 2022 at 03:52:15PM +0530, Arun Ramadoss wrote:
> The ksz88xx family has one set of mib_names. The ksz87xx, ksz9477,
> LAN937x based switches has one set of mib_names. In order to remove
> redundant declaration, moved the struct mib_names to ksz_chip_data
> structure. And allocated the mib memory in switch_register instead of
> individual switch_init function.
>
> Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
> ---
> static int ksz9477_switch_init(struct ksz_device *dev)
> {
> - int i;
> -
> dev->ds->ops = &ksz9477_switch_ops;
>
> dev->port_mask = (1 << dev->info->port_cnt) - 1;
>
> - dev->reg_mib_cnt = SWITCH_COUNTER_NUM;
> - dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM;
> -
> - for (i = 0; i < dev->info->port_cnt; i++) {
> - spin_lock_init(&dev->ports[i].mib.stats64_lock);
> - mutex_init(&dev->ports[i].mib.cnt_mutex);
> - dev->ports[i].mib.counters =
> - devm_kzalloc(dev->dev,
> - sizeof(u64) *
> - (TOTAL_SWITCH_COUNTER_NUM + 1),
> - GFP_KERNEL);
> - if (!dev->ports[i].mib.counters)
> - return -ENOMEM;
> - }
> -

This fixes the NULL pointer dereference on probe that was introduced in
the previous patch, but please make sure that this does not happen in
the first place, for bisectability purposes.

> return 0;
> }

\
 
 \ /
  Last update: 2022-05-16 13:24    [W:2.136 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site