io: io_stm32image: correct possible NULL pointer dereference

This issue was found with cppcheck in our downstream code:
[drivers/st/io/io_stm32image.c:234] -> [drivers/st/io/io_stm32image.c:244]:
 (warning) Either the condition 'buffer!=0U' is redundant or there is
 possible null pointer dereference: local_buffer.

Change-Id: Ieb615b7e485dc93bbeeed4cd8bf845eb84c14ac9
Signed-off-by: Yann Gautier <yann.gautier@st.com>
diff --git a/drivers/st/io/io_stm32image.c b/drivers/st/io/io_stm32image.c
index 413521b..3e377cd 100644
--- a/drivers/st/io/io_stm32image.c
+++ b/drivers/st/io/io_stm32image.c
@@ -247,7 +247,7 @@
 				     size_t length, size_t *length_read)
 {
 	int result;
-	uint8_t *local_buffer = (uint8_t *)buffer;
+	uint8_t *local_buffer;
 	boot_api_image_header_t *header =
 		(boot_api_image_header_t *)first_lba_buffer;
 
@@ -255,6 +255,7 @@
 	assert(buffer != 0U);
 	assert(length_read != NULL);
 
+	local_buffer = (uint8_t *)buffer;
 	*length_read = 0U;
 
 	while (*length_read == 0U) {