[PATCH] staging: Check for Null return of allocated skb in fw_download_code
Nick Krause
xerofoify at gmail.com
Tue Aug 12 23:14:46 EDT 2014
On Tue, Aug 12, 2014 at 11:12 PM, Nicholas Krause <xerofoify at gmail.com> wrote:
> This patch checks if we are getting a Null allocated skb in the while/do
> loop of this function. Further more no reference checking is needing
> as skb_put is only working with the packet defined by skb and not allocating
> a new one. Further more I am breaking out of the loop in order to make sure
> we call nic_write_byte and cause no errors with writing the nic byte(s) of
> private date and then call rt_status which I changed to false in the loop
> with my additon of checking the allocated skb.
>
> Signed-off-by: Nicholas Krause <xerofoify at gmail.com>
> ---
> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> index 1a95d1f..829af66 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> @@ -61,6 +61,10 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
> }
>
> skb = dev_alloc_skb(frag_length + 4);
> + if( skb == NULL) {
> + rt_status = false ;
> + break;
> + }
> memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
> tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
> tcb_desc->queue_index = TXCMD_QUEUE;
> --
> 1.9.1
>
If you didn't read my other emails, skb_put is not allocating another
skb and therefore no memory leaks
as you guys stated. By the way thanks for the input, I should have
read the code more carefully first.
Nick
More information about the Kernelnewbies
mailing list