Skip to content
Snippets Groups Projects
Commit 7188e595 authored by Guy Zana's avatar Guy Zana
Browse files

falloc(): call fdrop() instead of free() directly

In case there's an error installing the file descriptor (fdalloc() fails),
fdrop() should be called since it also functions as a desctructor
(encapsulation).
parent 07c1d3bb
No related branches found
No related tags found
No related merge requests found
...@@ -113,17 +113,15 @@ int falloc(struct file **resultfp, int *resultfd) ...@@ -113,17 +113,15 @@ int falloc(struct file **resultfp, int *resultfd)
return error; return error;
error = fdalloc(fp, &fd); error = fdalloc(fp, &fd);
if (error) if (error) {
goto out_free_fp; fdrop(fp);
return error;
}
/* Result */ /* Result */
*resultfp = fp; *resultfp = fp;
*resultfd = fd; *resultfd = fd;
return 0; return 0;
out_free_fp:
free(fp);
return error;
} }
void finit(struct file *fp, unsigned flags, filetype_t type, void *opaque, void finit(struct file *fp, unsigned flags, filetype_t type, void *opaque,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment