If buff_copy allocation failed then there was an error and the errbuf
allocation succeeded, it will not be logged or freed.

Signed-off-by: Nicholas Piggin <npig...@gmail.com>
---
 arch/powerpc/kernel/rtas.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index e047793cbb80..1fc22138e3ab 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1239,9 +1239,10 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
 
        unlock_rtas(flags);
 
-       if (buff_copy) {
-               if (errbuf)
-                       log_error(errbuf, ERR_TYPE_RTAS_LOG, 0);
+       if (errbuf) {
+               log_error(errbuf, ERR_TYPE_RTAS_LOG, 0);
+               kfree(errbuf);
+       } else if (buff_copy) {
                kfree(buff_copy);
        }
 
-- 
2.23.0

Reply via email to