kfree followed by a TRACE_RET before ref should be ok
PATCH 1/1 kfree followed by a TRACE_RET before ref should be ok
kfree.cocci currently triggers on constructs like
drivers/staging/rts5208/spi.c:
596 if (retval < 0) {
597 kfree(buf);
598 rtsx_clear_spi_error(chip);
599 spi_set_err_code(chip, SPI_HW_ERR);
600 TRACE_RET(chip, STATUS_FAIL);
601 }
602
603 rtsx_stor_access_xfer_buf(buf, pagelen, srb, &index, &offset,
TO_XFER_BUF);with:
./drivers/staging/rts5208/spi.c:603:28-31: ERROR: reference preceded by free on line 597
but this should be fine - so TRACE_RET is added to the list of calls "protecting" access to freed objects see drivers/staging/rts5208/trace.h
Acked-by Julia Lawall <[email protected]>
Signed-off-by Nicholas Mc Guire <[email protected]>
--- scripts/coccinelle/free/kfree.cocci | 2 ++ 1 file changed, 2 insertions(+)
scripts/coccinelle/free/kfree.cocci +2 -0
@@ -101,6 +101,8 @@ kfree at p1(E,...) | return_ACPI_STATUS(...) | + TRACE_RET(...) +| E at p2 // bad use )
Signature · 1 line
1.7.10.4