mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-21 01:51:18 +00:00
powerpc/pseries: Fix potential memleak in papr_get_attr()
[ Upstream commitcda9c0d556
] `buf` is allocated in papr_get_attr(), and krealloc() of `buf` could fail. We need to free the original `buf` in the case of failure. Fixes:3c14b73454
("powerpc/pseries: Interface to represent PAPR firmware attributes") Signed-off-by: Qiheng Lin <linqiheng@huawei.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20221208133449.16284-1-linqiheng@huawei.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d2bd30c710
commit
a3f22feb22
1 changed files with 5 additions and 3 deletions
|
@ -101,10 +101,12 @@ static int papr_get_attr(u64 id, struct energy_scale_attribute *esi)
|
|||
esi_buf_size = ESI_HDR_SIZE + (CURR_MAX_ESI_ATTRS * max_esi_attrs);
|
||||
|
||||
temp_buf = krealloc(buf, esi_buf_size, GFP_KERNEL);
|
||||
if (temp_buf)
|
||||
if (temp_buf) {
|
||||
buf = temp_buf;
|
||||
else
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
ret = -ENOMEM;
|
||||
goto out_buf;
|
||||
}
|
||||
|
||||
goto retry;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue