From mboxrd@z Thu Jan 1 00:00:00 1970 From: xerofoify@gmail.com (Nick Krause) Date: Tue, 12 Aug 2014 23:14:46 -0400 Subject: [PATCH] staging: Check for Null return of allocated skb in fw_download_code In-Reply-To: <1407899578-19730-1-git-send-email-xerofoify@gmail.com> References: <1407899578-19730-1-git-send-email-xerofoify@gmail.com> Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Tue, Aug 12, 2014 at 11:12 PM, Nicholas Krause 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 > --- > 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