Skip to content

Commit cac7100

Browse files
Yizhuo Zhaidtor
authored andcommitted
Input: hideep - fix the uninitialized use in hideep_nvm_unlock()
Inside function hideep_nvm_unlock(), variable "unmask_code" could be uninitialized if hideep_pgm_r_reg() returns error, however, it is used in the later if statement after an "and" operation, which is potentially unsafe. Signed-off-by: Yizhuo <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent eacacdb commit cac7100

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/input/touchscreen/hideep.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,16 @@ static int hideep_enter_pgm(struct hideep_ts *ts)
361361
return -EIO;
362362
}
363363

364-
static void hideep_nvm_unlock(struct hideep_ts *ts)
364+
static int hideep_nvm_unlock(struct hideep_ts *ts)
365365
{
366366
u32 unmask_code;
367+
int error;
367368

368369
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE);
369-
hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code);
370+
error = hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code);
370371
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
372+
if (error)
373+
return error;
371374

372375
/* make it unprotected code */
373376
unmask_code &= ~HIDEEP_PROT_MODE;
@@ -384,6 +387,8 @@ static void hideep_nvm_unlock(struct hideep_ts *ts)
384387
NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask);
385388
SET_FLASH_HWCONTROL();
386389
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
390+
391+
return 0;
387392
}
388393

389394
static int hideep_check_status(struct hideep_ts *ts)
@@ -462,7 +467,9 @@ static int hideep_program_nvm(struct hideep_ts *ts,
462467
u32 addr = 0;
463468
int error;
464469

465-
hideep_nvm_unlock(ts);
470+
error = hideep_nvm_unlock(ts);
471+
if (error)
472+
return error;
466473

467474
while (ucode_len > 0) {
468475
xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE);

0 commit comments

Comments
 (0)