Re: [PATCH 4.4 51/79] bnxt_en: Fix for system hang if request_irq fails

From: Michael Chan
Date: Tue Sep 11 2018 - 16:58:22 EST


On Tue, Sep 11, 2018 at 1:14 PM, Ben Hutchings
<ben.hutchings@xxxxxxxxxxxxxxx> wrote:
> On Thu, 2018-08-23 at 09:53 +0200, Greg Kroah-Hartman wrote:
>> 4.4-stable review patch. If anyone has any objections, please let me know.
>>
>> ------------------
>>
>> From: Vikas Gupta <vikas.gupta@xxxxxxxxxxxx>
>>
>> [ Upstream commit c58387ab1614f6d7fb9e244f214b61e7631421fc ]
>>
>> Fix bug in the error code path when bnxt_request_irq() returns failure.
>> bnxt_disable_napi() should not be called in this error path because
>> NAPI has not been enabled yet.
> [...]
>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> @@ -4591,7 +4591,7 @@ static int __bnxt_open_nic(struct bnxt *
>> rc = bnxt_request_irq(bp);
>> if (rc) {
>> netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc);
>> - goto open_err;
>> + goto open_err_irq;
>> }
>> }
>>
>> @@ -4629,6 +4629,8 @@ static int __bnxt_open_nic(struct bnxt *
>>
>> open_err:
>> bnxt_disable_napi(bp);
>> +
>> +open_err_irq:
>> bnxt_del_napi(bp);
>
> Shouldn't this added statement be conditional on irq_re_init?
>

Unconditional call is more correct, because when open fails, we clean
up everything, including the NAPI that was added just now or during a
previous call.

In other words, the NAPI struct is always valid here whether
irq_re_init is true or not. And we always delete it if open fails.

Thanks.