Skip to content

Commit

Permalink
um: NULL check before kfree is not needed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
YueHaibing authored and Richard Weinberger committed Oct 29, 2018
1 parent 369cca2 commit d312a25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
15 changes: 5 additions & 10 deletions arch/um/drivers/vector_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,16 +1118,11 @@ static int vector_net_close(struct net_device *dev)
os_close_file(vp->fds->tx_fd);
vp->fds->tx_fd = -1;
}
if (vp->bpf != NULL)
kfree(vp->bpf);
if (vp->fds->remote_addr != NULL)
kfree(vp->fds->remote_addr);
if (vp->transport_data != NULL)
kfree(vp->transport_data);
if (vp->header_rxbuffer != NULL)
kfree(vp->header_rxbuffer);
if (vp->header_txbuffer != NULL)
kfree(vp->header_txbuffer);
kfree(vp->bpf);
kfree(vp->fds->remote_addr);
kfree(vp->transport_data);
kfree(vp->header_rxbuffer);
kfree(vp->header_txbuffer);
if (vp->rx_queue != NULL)
destroy_queue(vp->rx_queue);
if (vp->tx_queue != NULL)
Expand Down
6 changes: 2 additions & 4 deletions arch/um/drivers/vector_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec)
os_close_file(rxfd);
if (txfd >= 0)
os_close_file(txfd);
if (result != NULL)
kfree(result);
kfree(result);
return NULL;
}

Expand Down Expand Up @@ -434,8 +433,7 @@ static struct vector_fds *user_init_socket_fds(struct arglist *ifspec, int id)
if (fd >= 0)
os_close_file(fd);
if (result != NULL) {
if (result->remote_addr != NULL)
kfree(result->remote_addr);
kfree(result->remote_addr);
kfree(result);
}
return NULL;
Expand Down
3 changes: 1 addition & 2 deletions arch/um/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ static void garbage_collect_irq_entries(void)
to_free = NULL;
}
walk = walk->next;
if (to_free != NULL)
kfree(to_free);
kfree(to_free);
}
}

Expand Down

0 comments on commit d312a25

Please sign in to comment.