diff --git a/cpukit/libmisc/shell/main_flashdev.c b/cpukit/libmisc/shell/main_flashdev.c index 3933e718e5..d55ffae89a 100644 --- a/cpukit/libmisc/shell/main_flashdev.c +++ b/cpukit/libmisc/shell/main_flashdev.c @@ -312,7 +312,12 @@ int flashdev_shell_write( /* Create buffer */ buffer = calloc(1, 0x1000); - + if (buffer == NULL) { + close(flash); + close(file); + printf("Failed to allocate write buffer\n"); + return -1; + } /* Write file to flash device in 0x1000 byte chunks */ offset = 0; while (offset != length) {