staging: wfx: fix uninitialized variable bytes_done
Subsystems (2)
PATCH 1/1 staging: wfx: fix uninitialized variable bytes_done
From: Colin Ian King <[email protected]>
The variable bytes_done is not initialized and hence the first FIFO size check on bytes_done may be breaking prematurely from the loop if bytes_done contains a large bogus uninitialized value. Fix this by initializing bytes_done to zero.
Addresses-Coverity: ("Uninitialized scalar variable")
--- drivers/staging/wfx/fwio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wfx/fwio.c +1 -1
@@ -177,7 +177,7 @@ static int wait_ncp_status(struct wfx_dev *wdev, u32 status)static int upload_firmware (struct wfx_dev *wdev,const u8 *data,size_t len) {int ret; -u32 offs, bytes_done; +u32 offs, bytes_done =0 ;ktime_t now, start;if (len %DNLD_BLOCK_SIZE ) {
Signature · 1 line
2.27.0
Quoted 11 lines · On Monday 6 July 2020 15:20:17 CEST Colin King wrote:
From: Colin Ian King <[email protected]>
The variable
bytes_doneis not initialized and hence the first FIFO size check onbytes_donemay be breaking prematurely from the loop ifbytes_donecontains a large bogus uninitialized value. Fix this by initializingbytes_doneto zero.Addresses-Coverity: ("Uninitialized scalar variable")
Fixes a9408ad79ff3 ("staging: wfx: load the firmware faster")Signed-off-by Colin Ian King <[email protected]>
Good catch!
I am surprised that my gcc hasn't caught that.
Quoted 21 lines
--- drivers/staging/wfx/fwio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/wfx/fwio.c +1
-2@@ -177,7 +177,7 @@ static int wait_ncp_status(struct wfx_dev *wdev, u32 status)static int upload_firmware (struct wfx_dev *wdev,const u8 *data,size_t len) {int ret; -u32 offs, bytes_done; +u32 offs, bytes_done =0 ;ktime_t now, start;if (len %DNLD_BLOCK_SIZE ) { --2.27.0
Signature · 1 line
Jérôme Pouiller