Patchwork [net,1/2] bnx2x: fix a crash on corrupt firmware file

login
register
mail settings
Submitter Michal Schmidt
Date March 16, 2012, 12:08 a.m.
Message ID <1331856509-9159-1-git-send-email-mschmidt@redhat.com>
Download mbox | patch
Permalink /patch/147119/
State Accepted
Delegated to: David Miller
Headers show

Comments

Michal Schmidt - March 16, 2012, 12:08 a.m.
If the requested firmware is deemed corrupt and then released, reset the
pointer to NULL in order to avoid double-freeing it in
bnx2x_release_firmware() or dereferencing it in bnx2x_init_firmware().

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Eilon Greenstein - March 16, 2012, 7:24 a.m.
On Fri, 2012-03-16 at 01:08 +0100, Michal Schmidt wrote:
> If the requested firmware is deemed corrupt and then released, reset the
> pointer to NULL in order to avoid double-freeing it in
> bnx2x_release_firmware() or dereferencing it in bnx2x_init_firmware().
> 
> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>

Acked-by: Eilon Greenstein <eilong@broadcom.com>

Thanks Michal!

> ---
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> index 2545213..00ff62f 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> @@ -10901,6 +10901,7 @@ init_ops_alloc_err:
>  	kfree(bp->init_data);
>  request_firmware_exit:
>  	release_firmware(bp->firmware);
> +	bp->firmware = NULL;
>  
>  	return rc;
>  }




--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - March 16, 2012, 8:57 a.m.
From: "Eilon Greenstein" <eilong@broadcom.com>
Date: Fri, 16 Mar 2012 09:24:09 +0200

> On Fri, 2012-03-16 at 01:08 +0100, Michal Schmidt wrote:
>> If the requested firmware is deemed corrupt and then released, reset the
>> pointer to NULL in order to avoid double-freeing it in
>> bnx2x_release_firmware() or dereferencing it in bnx2x_init_firmware().
>> 
>> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
> 
> Acked-by: Eilon Greenstein <eilong@broadcom.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 2545213..00ff62f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -10901,6 +10901,7 @@  init_ops_alloc_err:
 	kfree(bp->init_data);
 request_firmware_exit:
 	release_firmware(bp->firmware);
+	bp->firmware = NULL;
 
 	return rc;
 }