Skip to content

Commit 02a628a

Browse files
cyrilbur-ibmstewartsmith
authored andcommitted
external/pflash: Perform the correct cleanup
If the -F flag is used then pflash uses a regular file as the flash. On cleanup pflash fails to tell arch_flash_close() if it had passed a filename to arch_flash_init() as such arch_flash_close() assumes that it needs to close the actual flash structure and not simply a file descriptor leading to a NULL dereference. Signed-off-by: Cyril Bur <[email protected]> Signed-off-by: Stewart Smith <[email protected]>
1 parent 4e4db1a commit 02a628a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

external/pflash/pflash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
/* Full pflash version number (possibly includes gitid). */
4343
extern const char version[];
4444

45+
const char *flashfilename = NULL;
4546
static bool must_confirm = true;
4647
static bool dummy_run;
4748
static int need_relock;
@@ -524,7 +525,7 @@ void exiting(void)
524525
{
525526
if (need_relock)
526527
arch_flash_set_wrprotect(bl, 1);
527-
arch_flash_close(bl, NULL);
528+
arch_flash_close(bl, flashfilename);
528529
}
529530

530531
int main(int argc, char *argv[])
@@ -540,7 +541,6 @@ int main(int argc, char *argv[])
540541
char *write_file = NULL, *read_file = NULL, *part_name = NULL;
541542
bool ffs_toc_seen = false, direct = false;
542543
int rc;
543-
const char *flashfilename = NULL;
544544

545545
while(1) {
546546
struct option long_opts[] = {

0 commit comments

Comments
 (0)