lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240331085438.GA26556@kernel.org>
Date: Sun, 31 Mar 2024 09:54:38 +0100
From: Simon Horman <horms@...nel.org>
To: Breno Leitao <leitao@...ian.org>
Cc: aleksander.lobakin@...el.com, kuba@...nel.org, davem@...emloft.net,
	pabeni@...hat.com, edumazet@...gle.com,
	Taras Chornyi <taras.chornyi@...ision.eu>,
	quic_jjohnson@...cinc.com, kvalo@...nel.org, leon@...nel.org,
	dennis.dalessandro@...nelisnetworks.com,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/5] net: marvell: prestera: allocate dummy
 net_device dynamically

On Thu, Mar 28, 2024 at 04:52:02PM -0700, Breno Leitao wrote:
> Embedding net_device into structures prohibits the usage of flexible
> arrays in the net_device structure. For more details, see the discussion
> at [1].
> 
> Un-embed the net_device from the private struct by converting it
> into a pointer. Then use the leverage the new alloc_netdev_dummy()
> helper to allocate and initialize dummy devices.
> 
> [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
> 
> Signed-off-by: Breno Leitao <leitao@...ian.org>
> ---
>  .../net/ethernet/marvell/prestera/prestera_rxtx.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c b/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c

..

> @@ -654,13 +654,21 @@ static int prestera_sdma_switch_init(struct prestera_switch *sw)
>  	if (err)
>  		goto err_evt_register;
>  
> -	init_dummy_netdev(&sdma->napi_dev);
> +	sdma->napi_dev = alloc_netdev_dummy(0);
> +	if (!sdma->napi_dev) {
> +		dev_err(dev, "not able to initialize dummy device\n");
> +		goto err_alloc_dummy;

Hi Breno,

This goto will result in the function returning err.
But err is 0 here. Perhaps it should be set to a negative error value
instead?

Flagged by Smatch.

> +	}
> +
>  
> -	netif_napi_add(&sdma->napi_dev, &sdma->rx_napi, prestera_sdma_rx_poll);
> +	netif_napi_add(sdma->napi_dev, &sdma->rx_napi, prestera_sdma_rx_poll);
>  	napi_enable(&sdma->rx_napi);
>  
>  	return 0;
>  
> +err_alloc_dummy:
> +	prestera_hw_event_handler_unregister(sw, PRESTERA_EVENT_TYPE_RXTX,
> +					     prestera_rxtx_handle_event);
>  err_evt_register:
>  err_tx_init:
>  	prestera_sdma_tx_fini(sdma);

..

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ