powerpc/ptrace: Fix cppcheck issue in gpr32_set_common/gpr32_get_common()
The ckpt_regs usage in gpr32_set_common/gpr32_get_common() will lead to following cppcheck error at ifndef CONFIG_PPC_TRANSACTIONAL_MEM case: [arch/powerpc/kernel/ptrace.c:2062]: (error) Uninitialized variable: ckpt_regs [arch/powerpc/kernel/ptrace.c:2130]: (error) Uninitialized variable: ckpt_regs The problem is due to gpr32_set_common() used ckpt_regs variable which only makes sense at #ifdef CONFIG_PPC_TRANSACTIONAL_MEM. This patch fix this issue by passing in "regs" parameter instead. Reported-by: Daniel Axtens <dja@axtens.net> Signed-off-by: Simon Guo <wei.guo.simon@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
b135077b83
commit
261831160d
|
@ -2066,33 +2066,12 @@ static const struct user_regset_view user_ppc_native_view = {
|
||||||
static int gpr32_get_common(struct task_struct *target,
|
static int gpr32_get_common(struct task_struct *target,
|
||||||
const struct user_regset *regset,
|
const struct user_regset *regset,
|
||||||
unsigned int pos, unsigned int count,
|
unsigned int pos, unsigned int count,
|
||||||
void *kbuf, void __user *ubuf, bool tm_active)
|
void *kbuf, void __user *ubuf,
|
||||||
|
unsigned long *regs)
|
||||||
{
|
{
|
||||||
const unsigned long *regs = &target->thread.regs->gpr[0];
|
|
||||||
const unsigned long *ckpt_regs;
|
|
||||||
compat_ulong_t *k = kbuf;
|
compat_ulong_t *k = kbuf;
|
||||||
compat_ulong_t __user *u = ubuf;
|
compat_ulong_t __user *u = ubuf;
|
||||||
compat_ulong_t reg;
|
compat_ulong_t reg;
|
||||||
int i;
|
|
||||||
|
|
||||||
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
|
|
||||||
ckpt_regs = &target->thread.ckpt_regs.gpr[0];
|
|
||||||
#endif
|
|
||||||
if (tm_active) {
|
|
||||||
regs = ckpt_regs;
|
|
||||||
} else {
|
|
||||||
if (target->thread.regs == NULL)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
if (!FULL_REGS(target->thread.regs)) {
|
|
||||||
/*
|
|
||||||
* We have a partial register set.
|
|
||||||
* Fill 14-31 with bogus values.
|
|
||||||
*/
|
|
||||||
for (i = 14; i < 32; i++)
|
|
||||||
target->thread.regs->gpr[i] = NV_REG_POISON;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pos /= sizeof(reg);
|
pos /= sizeof(reg);
|
||||||
count /= sizeof(reg);
|
count /= sizeof(reg);
|
||||||
|
@ -2134,29 +2113,13 @@ static int gpr32_get_common(struct task_struct *target,
|
||||||
static int gpr32_set_common(struct task_struct *target,
|
static int gpr32_set_common(struct task_struct *target,
|
||||||
const struct user_regset *regset,
|
const struct user_regset *regset,
|
||||||
unsigned int pos, unsigned int count,
|
unsigned int pos, unsigned int count,
|
||||||
const void *kbuf, const void __user *ubuf, bool tm_active)
|
const void *kbuf, const void __user *ubuf,
|
||||||
|
unsigned long *regs)
|
||||||
{
|
{
|
||||||
unsigned long *regs = &target->thread.regs->gpr[0];
|
|
||||||
unsigned long *ckpt_regs;
|
|
||||||
const compat_ulong_t *k = kbuf;
|
const compat_ulong_t *k = kbuf;
|
||||||
const compat_ulong_t __user *u = ubuf;
|
const compat_ulong_t __user *u = ubuf;
|
||||||
compat_ulong_t reg;
|
compat_ulong_t reg;
|
||||||
|
|
||||||
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
|
|
||||||
ckpt_regs = &target->thread.ckpt_regs.gpr[0];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (tm_active) {
|
|
||||||
regs = ckpt_regs;
|
|
||||||
} else {
|
|
||||||
regs = &target->thread.regs->gpr[0];
|
|
||||||
|
|
||||||
if (target->thread.regs == NULL)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
CHECK_FULL_REGS(target->thread.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
pos /= sizeof(reg);
|
pos /= sizeof(reg);
|
||||||
count /= sizeof(reg);
|
count /= sizeof(reg);
|
||||||
|
|
||||||
|
@ -2221,7 +2184,8 @@ static int tm_cgpr32_get(struct task_struct *target,
|
||||||
unsigned int pos, unsigned int count,
|
unsigned int pos, unsigned int count,
|
||||||
void *kbuf, void __user *ubuf)
|
void *kbuf, void __user *ubuf)
|
||||||
{
|
{
|
||||||
return gpr32_get_common(target, regset, pos, count, kbuf, ubuf, 1);
|
return gpr32_get_common(target, regset, pos, count, kbuf, ubuf,
|
||||||
|
&target->thread.ckpt_regs.gpr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tm_cgpr32_set(struct task_struct *target,
|
static int tm_cgpr32_set(struct task_struct *target,
|
||||||
|
@ -2229,7 +2193,8 @@ static int tm_cgpr32_set(struct task_struct *target,
|
||||||
unsigned int pos, unsigned int count,
|
unsigned int pos, unsigned int count,
|
||||||
const void *kbuf, const void __user *ubuf)
|
const void *kbuf, const void __user *ubuf)
|
||||||
{
|
{
|
||||||
return gpr32_set_common(target, regset, pos, count, kbuf, ubuf, 1);
|
return gpr32_set_common(target, regset, pos, count, kbuf, ubuf,
|
||||||
|
&target->thread.ckpt_regs.gpr[0]);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
|
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
|
||||||
|
|
||||||
|
@ -2238,7 +2203,21 @@ static int gpr32_get(struct task_struct *target,
|
||||||
unsigned int pos, unsigned int count,
|
unsigned int pos, unsigned int count,
|
||||||
void *kbuf, void __user *ubuf)
|
void *kbuf, void __user *ubuf)
|
||||||
{
|
{
|
||||||
return gpr32_get_common(target, regset, pos, count, kbuf, ubuf, 0);
|
int i;
|
||||||
|
|
||||||
|
if (target->thread.regs == NULL)
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
if (!FULL_REGS(target->thread.regs)) {
|
||||||
|
/*
|
||||||
|
* We have a partial register set.
|
||||||
|
* Fill 14-31 with bogus values.
|
||||||
|
*/
|
||||||
|
for (i = 14; i < 32; i++)
|
||||||
|
target->thread.regs->gpr[i] = NV_REG_POISON;
|
||||||
|
}
|
||||||
|
return gpr32_get_common(target, regset, pos, count, kbuf, ubuf,
|
||||||
|
&target->thread.regs->gpr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpr32_set(struct task_struct *target,
|
static int gpr32_set(struct task_struct *target,
|
||||||
|
@ -2246,7 +2225,12 @@ static int gpr32_set(struct task_struct *target,
|
||||||
unsigned int pos, unsigned int count,
|
unsigned int pos, unsigned int count,
|
||||||
const void *kbuf, const void __user *ubuf)
|
const void *kbuf, const void __user *ubuf)
|
||||||
{
|
{
|
||||||
return gpr32_set_common(target, regset, pos, count, kbuf, ubuf, 0);
|
if (target->thread.regs == NULL)
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
CHECK_FULL_REGS(target->thread.regs);
|
||||||
|
return gpr32_set_common(target, regset, pos, count, kbuf, ubuf,
|
||||||
|
&target->thread.regs->gpr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue