Skip to content

Commit c5af2d2

Browse files
maurizio-lombardiigaw
authored andcommitted
plugins/solidigm: fix use after free.
the "output" file descriptor is automatically closed when the function returns; therefore we shouldn't explicitly call close() against it. Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
1 parent e152e97 commit c5af2d2

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

plugins/solidigm/solidigm-internal-logs.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ static int log_save(struct log *log, const char *parent_dir_name, const char *su
459459
_cleanup_fd_ int output = -1;
460460
char file_path[PATH_MAX] = {0};
461461
size_t bytes_remaining = 0;
462-
int err = 0;
463462

464463
ensure_dir(parent_dir_name, subdir_name);
465464

@@ -474,19 +473,14 @@ static int log_save(struct log *log, const char *parent_dir_name, const char *su
474473
while (bytes_remaining) {
475474
ssize_t bytes_written = write(output, buffer, bytes_remaining);
476475

477-
if (bytes_written < 0) {
478-
err = -errno;
479-
goto log_save_close_output;
480-
}
476+
if (bytes_written < 0)
477+
return -errno;
481478

482479
bytes_remaining -= bytes_written;
483480
buffer += bytes_written;
484481
}
485482
printf("Successfully wrote %s to %s\n", log->desc, file_path);
486-
487-
log_save_close_output:
488-
close(output);
489-
return err;
483+
return 0;
490484
}
491485

492486
static int ilog_dump_identify_page(struct ilog *ilog, struct log *cns, __u32 nsid)

0 commit comments

Comments
 (0)