um: NULL check before kfree is not needed

kfree(NULL) is safe,so this removes NULL check before freeing the mem

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
YueHaibing 2018-08-03 14:39:11 +08:00 committed by Richard Weinberger
parent 369cca2668
commit d312a25d47
3 changed files with 8 additions and 16 deletions

View File

@ -1118,16 +1118,11 @@ static int vector_net_close(struct net_device *dev)
os_close_file(vp->fds->tx_fd); os_close_file(vp->fds->tx_fd);
vp->fds->tx_fd = -1; vp->fds->tx_fd = -1;
} }
if (vp->bpf != NULL) kfree(vp->bpf);
kfree(vp->bpf); kfree(vp->fds->remote_addr);
if (vp->fds->remote_addr != NULL) kfree(vp->transport_data);
kfree(vp->fds->remote_addr); kfree(vp->header_rxbuffer);
if (vp->transport_data != NULL) kfree(vp->header_txbuffer);
kfree(vp->transport_data);
if (vp->header_rxbuffer != NULL)
kfree(vp->header_rxbuffer);
if (vp->header_txbuffer != NULL)
kfree(vp->header_txbuffer);
if (vp->rx_queue != NULL) if (vp->rx_queue != NULL)
destroy_queue(vp->rx_queue); destroy_queue(vp->rx_queue);
if (vp->tx_queue != NULL) if (vp->tx_queue != NULL)

View File

@ -267,8 +267,7 @@ cleanup:
os_close_file(rxfd); os_close_file(rxfd);
if (txfd >= 0) if (txfd >= 0)
os_close_file(txfd); os_close_file(txfd);
if (result != NULL) kfree(result);
kfree(result);
return NULL; return NULL;
} }
@ -434,8 +433,7 @@ cleanup:
if (fd >= 0) if (fd >= 0)
os_close_file(fd); os_close_file(fd);
if (result != NULL) { if (result != NULL) {
if (result->remote_addr != NULL) kfree(result->remote_addr);
kfree(result->remote_addr);
kfree(result); kfree(result);
} }
return NULL; return NULL;

View File

@ -244,8 +244,7 @@ static void garbage_collect_irq_entries(void)
to_free = NULL; to_free = NULL;
} }
walk = walk->next; walk = walk->next;
if (to_free != NULL) kfree(to_free);
kfree(to_free);
} }
} }