mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
Input: hideep - fix the uninitialized use in hideep_nvm_unlock()
[ Upstream commit cac7100d4c
]
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 <yzhai003@ucr.edu>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
5f5c1e6833
commit
86d56d5a59
1 changed files with 10 additions and 3 deletions
|
@ -361,13 +361,16 @@ static int hideep_enter_pgm(struct hideep_ts *ts)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
static void hideep_nvm_unlock(struct hideep_ts *ts)
|
||||
static int hideep_nvm_unlock(struct hideep_ts *ts)
|
||||
{
|
||||
u32 unmask_code;
|
||||
int error;
|
||||
|
||||
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE);
|
||||
hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code);
|
||||
error = hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code);
|
||||
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* make it unprotected code */
|
||||
unmask_code &= ~HIDEEP_PROT_MODE;
|
||||
|
@ -384,6 +387,8 @@ static void hideep_nvm_unlock(struct hideep_ts *ts)
|
|||
NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask);
|
||||
SET_FLASH_HWCONTROL();
|
||||
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hideep_check_status(struct hideep_ts *ts)
|
||||
|
@ -462,7 +467,9 @@ static int hideep_program_nvm(struct hideep_ts *ts,
|
|||
u32 addr = 0;
|
||||
int error;
|
||||
|
||||
hideep_nvm_unlock(ts);
|
||||
error = hideep_nvm_unlock(ts);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
while (ucode_len > 0) {
|
||||
xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE);
|
||||
|
|
Loading…
Reference in a new issue