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: <20240503085257.GM2821784@kernel.org>
Date: Fri, 3 May 2024 09:52:57 +0100
From: Simon Horman <horms@...nel.org>
To: Justin Lai <justinlai0215@...ltek.com>
Cc: kuba@...nel.org, davem@...emloft.net, edumazet@...gle.com,
	pabeni@...hat.com, linux-kernel@...r.kernel.org,
	netdev@...r.kernel.org, andrew@...n.ch, jiri@...nulli.us,
	pkshih@...ltek.com, larry.chiu@...ltek.com
Subject: Re: [PATCH net-next v17 02/13] rtase: Implement the .ndo_open
 function

On Thu, May 02, 2024 at 05:18:36PM +0800, Justin Lai wrote:
> Implement the .ndo_open function to set default hardware settings
> and initialize the descriptor ring and interrupts. Among them,
> when requesting irq, because the first group of interrupts needs to
> process more events, the overall structure will be different from
> other groups of interrupts, so it needs to be processed separately.
> 
> Signed-off-by: Justin Lai <justinlai0215@...ltek.com>

Hi Justin,

some minor feedback from my side.

> ---
>  .../net/ethernet/realtek/rtase/rtase_main.c   | 419 ++++++++++++++++++
>  1 file changed, 419 insertions(+)
> 
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index 5ddb5f7abfe9..b286aac1eedc 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -130,6 +130,293 @@ static u32 rtase_r32(const struct rtase_private *tp, u16 reg)
>  	return readl(tp->mmio_addr + reg);
>  }
>  
> +static void rtase_set_rxbufsize(struct rtase_private *tp)
> +{
> +	tp->rx_buf_sz = RTASE_RX_BUF_SIZE;
> +}

I'm a big fan of helpers, but maybe it's better to just open-code this one
as it is trivial and seems to only be used once.

...

> +static int rtase_open(struct net_device *dev)
> +{
> +	struct rtase_private *tp = netdev_priv(dev);
> +	struct rtase_int_vector *ivec = &tp->int_vector[0];
> +	const struct pci_dev *pdev = tp->pdev;
> +	u16 i, j;
> +	int ret;

nit: please use reverse xmas tree order - longest line to shortest -
     for local variable declarations in new Networking code.

> +
> +	rtase_set_rxbufsize(tp);
> +
> +	ret = rtase_alloc_desc(tp);
> +	if (ret)
> +		goto err_free_all_allocated_mem;
> +
> +	ret = rtase_init_ring(dev);
> +	if (ret)
> +		goto err_free_all_allocated_mem;
> +
> +	rtase_hw_config(dev);
> +
> +	if (tp->sw_flag & RTASE_SWF_MSIX_ENABLED) {
> +		ret = request_irq(ivec->irq, rtase_interrupt, 0,
> +				  dev->name, ivec);
> +		if (ret)
> +			goto err_free_all_allocated_irq;

This goto jumps to code that relies on i to set the bounds on a loop.
However, i is not initialised here. Perhaps it should be set to 1?

Flagged by Smatch, and clang-18 W=1 builds.

> +
> +		/* request other interrupts to handle multiqueue */
> +		for (i = 1; i < tp->int_nums; i++) {
> +			ivec = &tp->int_vector[i];
> +			snprintf(ivec->name, sizeof(ivec->name), "%s_int%i", tp->dev->name, i);

nit: This line could trivially be split into two lines,
     each less than 80 columns wide.

> +			ret = request_irq(ivec->irq, rtase_q_interrupt, 0,
> +					  ivec->name, ivec);
> +			if (ret)
> +				goto err_free_all_allocated_irq;
> +		}
> +	} else {
> +		ret = request_irq(pdev->irq, rtase_interrupt, 0, dev->name,
> +				  ivec);
> +		if (ret)
> +			goto err_free_all_allocated_mem;
> +	}
> +
> +	rtase_hw_start(dev);
> +
> +	for (i = 0; i < tp->int_nums; i++) {
> +		ivec = &tp->int_vector[i];
> +		napi_enable(&ivec->napi);
> +	}
> +
> +	netif_carrier_on(dev);
> +	netif_wake_queue(dev);
> +
> +	return 0;
> +
> +err_free_all_allocated_irq:
> +	for (j = 0; j < i; j++)
> +		free_irq(tp->int_vector[j].irq, &tp->int_vector[j]);
> +
> +err_free_all_allocated_mem:
> +	rtase_free_desc(tp);
> +
> +	return ret;
> +}

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ