Patch "libbpf: Use IS_ERR_OR_NULL() in hashmap__free()" has been added to the 5.10-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

    libbpf: Use IS_ERR_OR_NULL() in hashmap__free()

to the 5.10-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:
     libbpf-use-is_err_or_null-in-hashmap__free.patch
and it can be found in the queue-5.10 subdirectory.

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



commit a5ba4a9bb0982e29a8a046ca76e578bb2f8f74c2
Author: Mauricio Vásquez <mauricio@xxxxxxxxxx>
Date:   Fri Jan 7 10:26:19 2022 -0500

    libbpf: Use IS_ERR_OR_NULL() in hashmap__free()
    
    [ Upstream commit fba60b171a0322830b446dd28170092c47243d39 ]
    
    hashmap__new() uses ERR_PTR() to return an error so it's better to
    use IS_ERR_OR_NULL() in order to check the pointer before calling
    free(). This will prevent freeing an invalid pointer if somebody calls
    hashmap__free() with the result of a failed hashmap__new() call.
    
    Signed-off-by: Mauricio Vásquez <mauricio@xxxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Acked-by: Song Liu <songliubraving@xxxxxx>
    Link: https://lore.kernel.org/bpf/20220107152620.192327-1-mauricio@xxxxxxxxxx
    Stable-dep-of: 1fcc064b305a ("netfilter: rpfilter/fib: Set ->flowic_uid correctly for user namespaces.")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/hashmap.c b/tools/lib/bpf/hashmap.c
index 3c20b126d60d..aeb09c288716 100644
--- a/tools/lib/bpf/hashmap.c
+++ b/tools/lib/bpf/hashmap.c
@@ -75,7 +75,7 @@ void hashmap__clear(struct hashmap *map)
 
 void hashmap__free(struct hashmap *map)
 {
-	if (!map)
+	if (IS_ERR_OR_NULL(map))
 		return;
 
 	hashmap__clear(map);
@@ -238,4 +238,3 @@ bool hashmap__delete(struct hashmap *map, const void *key,
 
 	return true;
 }
-



[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