staging: Check for Null return of allocated skb in fw_download_code
PATCH 1/1 staging: Check for Null return of allocated skb in fw_download_code
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.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +4 -0
@@ -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 ;
Signature · 1 line
1.9.1
PATCH 1/1 staging: Check for Null return of allocated skb in fw_download_code
Quoted 29 lines · Nicholas Krause
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_putis 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 callnic_write_byteand cause no errors with writing the nic byte(s) of private date and then callrt_statuswhich I changed to false in the loop with my additon of checking the allocated skb.Signed-off-by Nicholas Krause <[email protected]>--- drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +4
-1@@ -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 ; --
Quoted 2 lines
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