Linux kernel staging patches
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Prashant Rahul <prashantrahul23@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shuah Khan <shuah@kernel.org>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] staging: octeon: handle rx/tx initialization failures in probe
Date: Mon, 29 Jun 2026 10:44:21 +0300	[thread overview]
Message-ID: <akIiVWOOfjbdM_G-@stanley.mountain> (raw)
In-Reply-To: <20260628-staging-driver-octeon-panic-v1-4-fe8c34989254@gmail.com>

On Sun, Jun 28, 2026 at 12:31:27PM +0530, Prashant Rahul wrote:
> Check return value of rx/tx initialization functions and abort probing
> if either one fails.
> 
> Add error handling labels to deallocate resources before returning the
> error.
> 
> Signed-off-by: Prashant Rahul <prashantrahul23@gmail.com>
> ---
>  drivers/staging/octeon/ethernet.c | 38 ++++++++++++++++++++++++++++++++++++--
>  1 file changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
> index 1d3bf3c79598d..41be73b2ded91 100644
> --- a/drivers/staging/octeon/ethernet.c
> +++ b/drivers/staging/octeon/ethernet.c
> @@ -688,6 +688,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
>  {
>  	int num_interfaces;
>  	int interface;
> +	int ret = 0;
>  	int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
>  	int qos;
>  	struct device_node *pip;
> @@ -934,17 +935,50 @@ static int cvm_oct_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	cvm_oct_tx_initialize(pdev);
> -	cvm_oct_rx_initialize(pdev);
> +	ret = cvm_oct_tx_initialize(pdev);
> +	if (ret)
> +		goto err_tx;
> +
> +	ret = cvm_oct_rx_initialize(pdev);
> +	if (ret)
> +		goto err_rx;
>  
>  	/*
>  	 * 150 uS: about 10 1500-byte packets at 1GE.
>  	 */
>  	cvm_oct_tx_poll_interval = 150 * (octeon_get_clock_rate() / 1000000);
>  
>  	schedule_delayed_work(&plat->rx_refill_work, HZ);
>  
>  	return 0;
> +
> +err_rx:
> +	cvm_oct_tx_shutdown();
> +err_tx:
> +	cvmx_ipd_disable();
> +
> +	atomic_inc_return(&cvm_oct_poll_queue_stopping);
> +
> +	cvmx_pko_disable();
> +
> +	/* Free the ethernet devices */
> +	for (int port = 0; port < TOTAL_NUMBER_OF_PORTS; port++)
> +		cvm_oct_remove_device(port);
> +
> +	cvmx_pko_shutdown();

This is all copied from the shutdown and it looks basically
reasonable to me.  This is staging code so of course it's a
bit wonky.  cvmx_pko_shutdown() has a built in call to
cvmx_pko_disable() so why are we calling that separately?

Also I feel like probe() should fail if alloc_netdev() fails
or register_netdev(), but that's not introduced by this patch
either.  And I have no way to test this.  Even reviewing MIPS
code is a pain in the behind because I don't have the cross
compiler set up.

Reviewed-by: Dan Carpenter <error27@gmail.com>

regards,
dan carpenter



  reply	other threads:[~2026-06-29  7:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-28  7:01 [PATCH 0/4] staging: octeon: Improve initialization error handling Prashant Rahul
2026-06-28  7:01 ` [PATCH 1/4] staging: octeon: factor out device removal into a helper Prashant Rahul
2026-06-29  7:25   ` Dan Carpenter
2026-06-29  7:45   ` Dan Carpenter
2026-06-28  7:01 ` [PATCH 2/4] staging: octeon: Propagate rx initialization failures Prashant Rahul
2026-06-28  7:01 ` [PATCH 3/4] staging: octeon: Propagate tx " Prashant Rahul
2026-06-28  7:01 ` [PATCH 4/4] staging: octeon: handle rx/tx initialization failures in probe Prashant Rahul
2026-06-29  7:44   ` Dan Carpenter [this message]
2026-06-29 16:19     ` Prashant Rahul
2026-06-29 19:40       ` Dan Carpenter
2026-06-29  7:24 ` [PATCH 0/4] staging: octeon: Improve initialization error handling Dan Carpenter
2026-06-29  8:25   ` Prashant Rahul
2026-06-29  8:45     ` Dan Carpenter
2026-06-29 20:20 ` Klara Modin

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=akIiVWOOfjbdM_G-@stanley.mountain \
    --to=error27@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=prashantrahul23@gmail.com \
    --cc=shuah@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox