Commit 16b9ce83fb850602794a3bc534693362408a5408

Authored by Markus Pargmann
Committed by Antonio Quartulli
1 parent 9bb218828c

batman-adv: tvlv realloc, move error handling into if block

Instead of hiding the normal function flow inside an if block, we should
just put the error handling into the if block.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>

Showing 1 changed file with 8 additions and 8 deletions Side-by-side Diff

net/batman-adv/main.c
... ... @@ -819,15 +819,15 @@
819 819 new_buff = kmalloc(min_packet_len + additional_packet_len, GFP_ATOMIC);
820 820  
821 821 /* keep old buffer if kmalloc should fail */
822   - if (new_buff) {
823   - memcpy(new_buff, *packet_buff, min_packet_len);
824   - kfree(*packet_buff);
825   - *packet_buff = new_buff;
826   - *packet_buff_len = min_packet_len + additional_packet_len;
827   - return true;
828   - }
  822 + if (!new_buff)
  823 + return false;
829 824  
830   - return false;
  825 + memcpy(new_buff, *packet_buff, min_packet_len);
  826 + kfree(*packet_buff);
  827 + *packet_buff = new_buff;
  828 + *packet_buff_len = min_packet_len + additional_packet_len;
  829 +
  830 + return true;
831 831 }
832 832  
833 833 /**