2021-01-21 07:34:41

by Abaci Team

[permalink] [raw]
Subject: [PATCH] mm/swap_slots.c: remove redundant NULL check

Fix below warnings reported by coccicheck:
./mm/swap_slots.c:197:3-9: WARNING: NULL check before some freeing
functions is not needed.

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Yang Li <[email protected]>
---
mm/swap_slots.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/swap_slots.c b/mm/swap_slots.c
index 0357fbe..be9de6d 100644
--- a/mm/swap_slots.c
+++ b/mm/swap_slots.c
@@ -193,8 +193,7 @@ static void drain_slots_cache_cpu(unsigned int cpu, unsigned int type,
cache->slots_ret = NULL;
}
spin_unlock_irq(&cache->free_lock);
- if (slots)
- kvfree(slots);
+ kvfree(slots);
}
}

--
1.8.3.1


2021-02-02 10:17:47

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] mm/swap_slots.c: remove redundant NULL check

On 21.01.21 08:30, Yang Li wrote:
> Fix below warnings reported by coccicheck:
> ./mm/swap_slots.c:197:3-9: WARNING: NULL check before some freeing
> functions is not needed.
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Yang Li <[email protected]>
> ---
> mm/swap_slots.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/swap_slots.c b/mm/swap_slots.c
> index 0357fbe..be9de6d 100644
> --- a/mm/swap_slots.c
> +++ b/mm/swap_slots.c
> @@ -193,8 +193,7 @@ static void drain_slots_cache_cpu(unsigned int cpu, unsigned int type,
> cache->slots_ret = NULL;
> }
> spin_unlock_irq(&cache->free_lock);
> - if (slots)
> - kvfree(slots);
> + kvfree(slots);
> }
> }
>
>

Reviewed-by: David Hildenbrand <[email protected]>

--
Thanks,

David / dhildenb