Re: [PATCH] MM: kmemleak: Removed coding style warnings and added a NULL check

From: Catalin Marinas
Date: Wed Nov 08 2023 - 05:41:16 EST


On Tue, Nov 07, 2023 at 10:27:56PM -0800, Omkar Wagle wrote:
> @@ -406,10 +406,13 @@ static struct kmemleak_object *__lookup_object(unsigned long ptr, int alias,
> unsigned long untagged_ptr = (unsigned long)kasan_reset_tag((void *)ptr);
>
> while (rb) {
> - struct kmemleak_object *object;
> + struct kmemleak_object *object = NULL;
> unsigned long untagged_objp;
>
> object = rb_entry(rb, struct kmemleak_object, rb_node);
> + if (!object)
> + break;

No need for this. rb_entry() is a container_of() and we already check
that rb is not NULL.

> @@ -1027,7 +1030,7 @@ static void object_no_scan(unsigned long ptr)
> void __ref kmemleak_alloc(const void *ptr, size_t size, int min_count,
> gfp_t gfp)
> {
> - pr_debug("%s(0x%px, %zu, %d)\n", __func__, ptr, size, min_count);
> + pr_debug("%s(0x%p, %zu, %d)\n", __func__, ptr, size, min_count);

That's for debugging, I'd rather keep the %px option. The same comment
applies to all the other pr_debug() changes in this file.

--
Catalin