Subject: Re: [PATCH] ieee802154: ca8210: Add missing check for kfifo_alloc() in ca8210_probe()

From: Simon Horman <[email-masked]>
Date: Mon, 4 Nov 2024 12:12:16 +0000

+ Marcel

On Tue, Oct 29, 2024 at 07:27:12PM +0100, Keisuke Nishimura wrote:
> ca8210_test_interface_init() returns the result of kfifo_alloc(),
> which can be non-zero in case of an error. The caller, ca8210_probe(),
> should check the return value and do error-handling if it fails.
> 
> Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
> Signed-off-by: Keisuke Nishimura <[email-masked]>
> ---
>  drivers/net/ieee802154/ca8210.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index e685a7f946f0..753215ebc67c 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -3072,7 +3072,11 @@ static int ca8210_probe(struct spi_device *spi_device)
>  	spi_set_drvdata(priv->spi, priv);
>  	if (IS_ENABLED(CONFIG_IEEE802154_CA8210_DEBUGFS)) {
>  		cascoda_api_upstream = ca8210_test_int_driver_write;
> -		ca8210_test_interface_init(priv);
> +		ret = ca8210_test_interface_init(priv);
> +		if (ret) {
> +			dev_crit(&spi_device->dev, "ca8210_test_interface_init failed\n");
> +			goto error;

Hi Nishimura-san,

I see that this will conditionally call kfifo_free().
Is that safe here? And in branches to error above this point?

> +		}
>  	} else {
>  		cascoda_api_upstream = NULL;
>  	}
> -- 
> 2.34.1
> 
>