Skip to content

Commit

Permalink
examples: linux: Close file on error in bind_rpmsg_chrdev
Browse files Browse the repository at this point in the history
The file should be closed when returning from this function in the error
path. Fix this here.

Signed-off-by: Andrew Davis <afd@ti.com>
  • Loading branch information
glneo authored and arnopo committed Jul 21, 2023
1 parent 2c5d206 commit db1f74a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/linux/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ int bind_rpmsg_chrdev(const char *rpmsg_dev_name)
if (ret < 0) {
fprintf(stderr, "Failed to write %s to %s, %s\n",
rpmsg_chdrv, fpath, strerror(errno));
close(fd);
return -EINVAL;
}
close(fd);
Expand All @@ -101,6 +102,7 @@ int bind_rpmsg_chrdev(const char *rpmsg_dev_name)
if (ret < 0) {
fprintf(stderr, "Failed to write %s to %s, %s\n",
rpmsg_dev_name, fpath, strerror(errno));
close(fd);
return -EINVAL;
}
close(fd);
Expand Down

0 comments on commit db1f74a

Please sign in to comment.