tools/jlink-nuttx: Move the register index check to setget_reg

avoid access tcbinfo before initializing it in update_tcbinfo

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-06-25 20:07:08 +08:00 committed by Petro Karashchenko
parent 252985fc1d
commit 4c2b7f3ac9

View File

@ -252,6 +252,11 @@ static int setget_reg(struct plugin_priv_s *priv, uint32_t idx,
{
uint32_t regaddr;
if (regidx >= priv->tcbinfo->total_num)
{
return -EINVAL;
}
if (priv->tcbinfo->reg_offs[regidx] == UINT16_MAX)
{
if (write == 0)
@ -597,11 +602,6 @@ int RTOS_GetThreadReg(char *hexregval, uint32_t regindex, uint32_t threadid)
return -ENOTSUP;
}
if (regindex > g_plugin_priv.tcbinfo->total_num)
{
return -EINVAL;
}
idx = get_idx_from_pid(&g_plugin_priv, threadid);
if (idx < 0)
{
@ -670,11 +670,6 @@ int RTOS_SetThreadReg(char *hexregval,
return -ENOTSUP;
}
if (regindex > g_plugin_priv.tcbinfo->total_num)
{
return -EINVAL;
}
idx = get_idx_from_pid(&g_plugin_priv, threadid);
if (idx < 0)
{