提交 300f3dee 编写于 作者: Y Yizhuo Zhai 提交者: Yang Yingliang

Input: hideep - fix the uninitialized use in hideep_nvm_unlock()

stable inclusion
from linux-4.19.198
commit c71a120d34dcda696664c1ee74868f217d4fc4b6

--------------------------------

[ Upstream commit cac7100d ]

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: NYizhuo <yzhai003@ucr.edu>
Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 d49813c4
...@@ -364,13 +364,16 @@ static int hideep_enter_pgm(struct hideep_ts *ts) ...@@ -364,13 +364,16 @@ static int hideep_enter_pgm(struct hideep_ts *ts)
return -EIO; return -EIO;
} }
static void hideep_nvm_unlock(struct hideep_ts *ts) static int hideep_nvm_unlock(struct hideep_ts *ts)
{ {
u32 unmask_code; u32 unmask_code;
int error;
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE); 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); hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
if (error)
return error;
/* make it unprotected code */ /* make it unprotected code */
unmask_code &= ~HIDEEP_PROT_MODE; unmask_code &= ~HIDEEP_PROT_MODE;
...@@ -387,6 +390,8 @@ static void hideep_nvm_unlock(struct hideep_ts *ts) ...@@ -387,6 +390,8 @@ static void hideep_nvm_unlock(struct hideep_ts *ts)
NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask); NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask);
SET_FLASH_HWCONTROL(); SET_FLASH_HWCONTROL();
hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE); hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
return 0;
} }
static int hideep_check_status(struct hideep_ts *ts) static int hideep_check_status(struct hideep_ts *ts)
...@@ -465,7 +470,9 @@ static int hideep_program_nvm(struct hideep_ts *ts, ...@@ -465,7 +470,9 @@ static int hideep_program_nvm(struct hideep_ts *ts,
u32 addr = 0; u32 addr = 0;
int error; int error;
hideep_nvm_unlock(ts); error = hideep_nvm_unlock(ts);
if (error)
return error;
while (ucode_len > 0) { while (ucode_len > 0) {
xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE); xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册