powerpc/pseries: Fix potential memleak in papr_get_attr()
`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
This commit is contained in:
committed by
Michael Ellerman
parent
6035e7e354
commit
cda9c0d556
@ -101,10 +101,12 @@ retry:
|
|||||||
esi_buf_size = ESI_HDR_SIZE + (CURR_MAX_ESI_ATTRS * max_esi_attrs);
|
esi_buf_size = ESI_HDR_SIZE + (CURR_MAX_ESI_ATTRS * max_esi_attrs);
|
||||||
|
|
||||||
temp_buf = krealloc(buf, esi_buf_size, GFP_KERNEL);
|
temp_buf = krealloc(buf, esi_buf_size, GFP_KERNEL);
|
||||||
if (temp_buf)
|
if (temp_buf) {
|
||||||
buf = temp_buf;
|
buf = temp_buf;
|
||||||
else
|
} else {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto out_buf;
|
||||||
|
}
|
||||||
|
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user