Subject: Re: [PATCH net v4 3/7] octeon_ep: add protective null checks in napi callbacks for cn9k cards

From: Vadim Fedorenko <[email-masked]>
Date: Wed, 13 Nov 2024 17:59:42 +0000

On 13/11/2024 11:13, Shinas Rasheed wrote:
> During unload, at times the OQ parsed in the napi callbacks
> have been observed to be null, causing system crash.
> Add protective checks to avoid the same, for cn9k cards.
> 
> Fixes: 1f2c2d0cee02 ("octeon_ep: add hardware configuration APIs")
> Signed-off-by: Shinas Rasheed <[email-masked]>
> ---
> V4:
>    - No changes
> 
> V3: https://lore.kernel.org/all/[email-masked]/
>    - Added back "Fixes" to the changelist
> 
> V2: https://lore.kernel.org/all/[email-masked]/
>    - Split into a separate patch
>    - Added more context
> 
> V1: https://lore.kernel.org/all/[email-masked]/
> 
>   drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c b/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c
> index b5805969404f..b87336b2e4b9 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c
> @@ -617,7 +617,14 @@ static irqreturn_t octep_rsvd_intr_handler_cn93_pf(void *dev)
>   static irqreturn_t octep_ioq_intr_handler_cn93_pf(void *data)
>   {
>   	struct octep_ioq_vector *vector = (struct octep_ioq_vector *)data;
> -	struct octep_oq *oq = vector->oq;
> +	struct octep_oq *oq;
> +
> +	if (!vector)
> +		return IRQ_HANDLED;

Sorry for not flagging in previous review, but the question is again the
same - how that can happen? This function is irq handler, which is
called from octep_ioq_intr_handler() only if ioq_vector was properly
resolved. This check makes no sense here.

> +	oq = vector->oq;
> +
> +	if (!oq || !(oq->napi))
> +		return IRQ_HANDLED;
>   
>   	napi_schedule_irqoff(oq->napi);
>   	return IRQ_HANDLED;