Patch "powerpc/boot: Handle allocation failure in simple_realloc()" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    powerpc/boot: Handle allocation failure in simple_realloc()

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     powerpc-boot-handle-allocation-failure-in-simple_rea.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 71ce334380aec84d5b2186531df70337e9ef5857
Author: Li zeming <zeming@xxxxxxxxxxxx>
Date:   Mon Dec 19 10:18:16 2022 +0800

    powerpc/boot: Handle allocation failure in simple_realloc()
    
    [ Upstream commit 69b0194ccec033c208b071e019032c1919c2822d ]
    
    simple_malloc() will return NULL when there is not enough memory left.
    Check pointer 'new' before using it to copy the old data.
    
    Signed-off-by: Li zeming <zeming@xxxxxxxxxxxx>
    [mpe: Reword subject, use change log from Christophe]
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://msgid.link/20221219021816.3012-1-zeming@xxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c
index 65ec135d01579..188c4f996512a 100644
--- a/arch/powerpc/boot/simple_alloc.c
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -114,7 +114,9 @@ static void *simple_realloc(void *ptr, unsigned long size)
 		return ptr;
 
 	new = simple_malloc(size);
-	memcpy(new, ptr, p->size);
+	if (new)
+		memcpy(new, ptr, p->size);
+
 	simple_free(ptr);
 	return new;
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux