Skip to content

Commit

Permalink
cxl/list: always free the path var in add_cxl_decoder()
Browse files Browse the repository at this point in the history
Static analysis reported a resource leak where the 'path' variable was
not always freed before returns.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 4656497 ("cxl/list: Add decoder support")
Signed-off-by: Alison Schofield <[email protected]>
Signed-off-by: Vishal Verma <[email protected]>
  • Loading branch information
AlisonSchofield authored and stellarhopper committed Mar 4, 2022
1 parent 367593e commit 7564aee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cxl/lib/libcxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,13 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
cxl_decoder_foreach(port, decoder_dup)
if (decoder_dup->id == decoder->id) {
free_decoder(decoder, NULL);
free(path);
return decoder_dup;
}

list_add(&port->decoders, &decoder->list);

free(path);
return decoder;

err_decoder:
Expand Down

0 comments on commit 7564aee

Please sign in to comment.