Message ID | 20210724150605.567038-1-festevam@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/3] stream_interface: Close the file descriptor on failure | expand |
On Sat, Jul 24, 2021 at 12:06 PM Fabio Estevam <festevam@gmail.com> wrote: > > When img_check_free_space() fails the previously acquired file > descriptor should be closed. > > Signed-off-by: Fabio Estevam <festevam@gmail.com> Sorry for sending the series twice. The first one missed the third patch. Thanks
Hi Fabio, On 24.07.21 17:06, Fabio Estevam wrote: > When img_check_free_space() fails the previously acquired file > descriptor should be closed. > > Signed-off-by: Fabio Estevam <festevam@gmail.com> > --- > core/stream_interface.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/core/stream_interface.c b/core/stream_interface.c > index efa9cbd64edb..da0c73353e50 100644 > --- a/core/stream_interface.c > +++ b/core/stream_interface.c > @@ -222,8 +222,10 @@ static int extract_files(int fd, struct swupdate_cfg *software) > fdout = openfileoutput(img->extract_file); > if (fdout < 0) > return -1; > - if (!img_check_free_space(img, fdout)) > + if (!img_check_free_space(img, fdout)) { > + close(fdout); > return -1; > + } > if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, false, NULL, NULL) < 0) { > close(fdout); > return -1; > Series applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/core/stream_interface.c b/core/stream_interface.c index efa9cbd64edb..da0c73353e50 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -222,8 +222,10 @@ static int extract_files(int fd, struct swupdate_cfg *software) fdout = openfileoutput(img->extract_file); if (fdout < 0) return -1; - if (!img_check_free_space(img, fdout)) + if (!img_check_free_space(img, fdout)) { + close(fdout); return -1; + } if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, false, NULL, NULL) < 0) { close(fdout); return -1;
When img_check_free_space() fails the previously acquired file descriptor should be closed. Signed-off-by: Fabio Estevam <festevam@gmail.com> --- core/stream_interface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)