[PATCH 00/20] fix memory leaks in error handling
David Marchand
david.marchand at redhat.com
Thu Jun 2 10:06:13 CEST 2022
On Tue, Feb 22, 2022 at 7:18 PM Weiguo Li <liwg06 at foxmail.com> wrote:
>
> This series fix some memory leaks in error handling.
>
> I write a coccinelle script to detect these issues, and
> fix them after exclude a small number of false positives.
>
> FYI, the script is as follows:
> //
> // Find possible memory leaks in error handling
> // Reference: coccinellery/alloc9/kmalloc9.cocci
> //
> @memory_leak_in_error_handling @
> local idexpression x;
> expression E;
> statement S;
> identifier dpdk_malloc = { rte_malloc, rte_zmalloc, rte_realloc, rte_malloc_socket,
> rte_zmalloc_socket, rte_realloc_socket, rte_pktmbuf_alloc, opae_malloc,
> strdup, strndup, malloc, realloc, calloc };
> identifier dpdk_free = { rte_free, free, bnx2x_rx_queue_release, bnx2x_tx_queue_release,
> rte_pktmbuf_free, opae_free, ntb_rxq_release, ntb_txq_release, ice_rx_queue_release,
> ice_tx_queue_release };
> type T;
> @@
> (
> /* skip this pattern to reduce false positives */
> x = dpdk_malloc(...); ... if (...) { ... \( return x; \| return 0; \) }
> |
> * x = dpdk_malloc(...);
> ...
> if (x == NULL) S
> ... when != E = x
> when != dpdk_free (..., \( x \| (T)x \| &x \), ...)
> when forall
> if (...) {
> <+... when != E = x
> when != dpdk_free (..., \( x \| (T)x \| &x \), ...)
> when forall
> * return ...;
> ...+>
> }
> )
Thanks for those who did reviews, but there are a lot of unattended
fixes in this series.
Reviews please!
--
David Marchand
More information about the dev
mailing list