Skip to content

Commit

Permalink
Free port in init_ports()
Browse files Browse the repository at this point in the history
Don't leak memory when the port is destroyed after failed
initialization.

Signed-off-by: Miroslav Lichvar <[email protected]>
  • Loading branch information
mlichvar authored and mmichaliINTC committed Jun 7, 2023
1 parent fd21863 commit b35ba59
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions synce_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ static int init_ports(int *count, struct synce_dev *dev, struct config *cfg)
pr_err("failed to configure port %s on device %s",
port_name, dev->name);
synce_port_destroy(port);
free(port);
continue;
}

if (add_port(dev, port)) {
pr_err("failed to add port %s to device %s",
port_name, dev->name);
synce_port_destroy(port);
free(port);
continue;
} else {
(*count)++;
Expand Down

0 comments on commit b35ba59

Please sign in to comment.