diff options
author | Simon Busch <morphis@gravedo.de> | 2011-10-12 15:21:19 +0200 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2011-10-12 15:22:20 +0200 |
commit | 3581333e33fa0b9da1d84e820bf844d14b8439b3 (patch) | |
tree | b09c5041518d006ca86bf264d52b7a52cb802b7a /samsung-ipc | |
parent | f3e39851e98d2b76f0db271a401368095bb9f8bf (diff) | |
download | external_libsamsung-ipc-3581333e33fa0b9da1d84e820bf844d14b8439b3.zip external_libsamsung-ipc-3581333e33fa0b9da1d84e820bf844d14b8439b3.tar.gz external_libsamsung-ipc-3581333e33fa0b9da1d84e820bf844d14b8439b3.tar.bz2 |
crespo: if reading nv data from filesystem fail handle this correctly
As already did for reading the radio image we need to check for errors when reading the nv
data too. Otherwise we continue but have no data to proceed which ends in a segmentation
fault.
Signed-off-by: Simon Busch <morphis@gravedo.de>
Diffstat (limited to 'samsung-ipc')
-rw-r--r-- | samsung-ipc/crespo_ipc.c | 2 | ||||
-rw-r--r-- | samsung-ipc/util.c | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/samsung-ipc/crespo_ipc.c b/samsung-ipc/crespo_ipc.c index 37209bc..1aaad4a 100644 --- a/samsung-ipc/crespo_ipc.c +++ b/samsung-ipc/crespo_ipc.c @@ -260,6 +260,8 @@ boot_loop_start: printf("crespo_ipc_bootstrap: write nv_data to modem_ctl\n"); nv_data_p = file_read("/efs/nv_data.bin", NV_DATA_SIZE, 1024); + if (nv_data_p == NULL) + goto error; data_p = nv_data_p; lseek(modem_ctl_fd, RADIO_IMG_SIZE, SEEK_SET); diff --git a/samsung-ipc/util.c b/samsung-ipc/util.c index 197a939..e7692d4 100644 --- a/samsung-ipc/util.c +++ b/samsung-ipc/util.c @@ -185,6 +185,10 @@ void *file_read(char *file_name, int size, int block_size) printf("file_read: reading 0x%x bytes from %s with 0x%x bytes block size\n", size, file_name, block_size); + fd=open(file_name, O_RDONLY); + if(fd < 0) + goto error; + file_p=malloc(size); if(file_p == NULL) goto error; @@ -193,10 +197,6 @@ void *file_read(char *file_name, int size, int block_size) data_p=(uint8_t *) file_p; - fd=open(file_name, O_RDONLY); - if(fd < 0) - goto error; - for(i=0 ; i < size / block_size ; i++) { read(fd, data_p, block_size); |