2020-09-27 13:04:09

by Julia Lawall

[permalink] [raw]
Subject: [PATCH] kvfree_rcu(): fix ifnullfree.cocci warnings

From: kernel test robot <[email protected]>

NULL check before kfree is not needed.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

Fixes: e9bed2a1239b ("kvfree_rcu(): Switch to kmalloc() and kfree() for allocations")
Signed-off-by: kernel test robot <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>
---

tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git urezki-pcount.2020.09.26a
head: 1a8eee1cc5b0e59c17f5d94c5871e6c70c4a43a1
commit: e9bed2a1239b017d78cec5de66adce0560f6d077 [17/18] kvfree_rcu(): Switch to kmalloc() and kfree() for allocations
:::::: branch date: 4 hours ago
:::::: commit date: 15 hours ago

tree.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3165,8 +3165,7 @@ static void kfree_rcu_work(struct work_s
bkvhead[i] = NULL;
krc_this_cpu_unlock(krcp, flags);

- if (bkvhead[i])
- kfree(bkvhead[i]);
+ kfree(bkvhead[i]);

cond_resched_tasks_rcu_qs();
}


2020-09-27 22:56:40

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH] kvfree_rcu(): fix ifnullfree.cocci warnings

On Sun, Sep 27, 2020 at 03:00:29PM +0200, Julia Lawall wrote:
> From: kernel test robot <[email protected]>
>
> NULL check before kfree is not needed.
>
> Generated by: scripts/coccinelle/free/ifnullfree.cocci
>
> Fixes: e9bed2a1239b ("kvfree_rcu(): Switch to kmalloc() and kfree() for allocations")
> Signed-off-by: kernel test robot <[email protected]>
> Signed-off-by: Julia Lawall <[email protected]>
> ---
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git urezki-pcount.2020.09.26a
> head: 1a8eee1cc5b0e59c17f5d94c5871e6c70c4a43a1
> commit: e9bed2a1239b017d78cec5de66adce0560f6d077 [17/18] kvfree_rcu(): Switch to kmalloc() and kfree() for allocations
> :::::: branch date: 4 hours ago
> :::::: commit date: 15 hours ago
>
> tree.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3165,8 +3165,7 @@ static void kfree_rcu_work(struct work_s
> bkvhead[i] = NULL;
> krc_this_cpu_unlock(krcp, flags);
>
> - if (bkvhead[i])
> - kfree(bkvhead[i]);
> + kfree(bkvhead[i]);
>

Acked-by: Joel Fernandes (Google) <[email protected]>

thanks,

- Joel

> cond_resched_tasks_rcu_qs();
> }

2020-09-28 14:06:28

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH] kvfree_rcu(): fix ifnullfree.cocci warnings

On Sun, Sep 27, 2020 at 06:55:19PM -0400, Joel Fernandes wrote:
> On Sun, Sep 27, 2020 at 03:00:29PM +0200, Julia Lawall wrote:
> > From: kernel test robot <[email protected]>
> >
> > NULL check before kfree is not needed.
> >
> > Generated by: scripts/coccinelle/free/ifnullfree.cocci
> >
> > Fixes: e9bed2a1239b ("kvfree_rcu(): Switch to kmalloc() and kfree() for allocations")
> > Signed-off-by: kernel test robot <[email protected]>
> > Signed-off-by: Julia Lawall <[email protected]>
> > ---
> >
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git urezki-pcount.2020.09.26a
> > head: 1a8eee1cc5b0e59c17f5d94c5871e6c70c4a43a1
> > commit: e9bed2a1239b017d78cec5de66adce0560f6d077 [17/18] kvfree_rcu(): Switch to kmalloc() and kfree() for allocations
> > :::::: branch date: 4 hours ago
> > :::::: commit date: 15 hours ago
> >
> > tree.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -3165,8 +3165,7 @@ static void kfree_rcu_work(struct work_s
> > bkvhead[i] = NULL;
> > krc_this_cpu_unlock(krcp, flags);
> >
> > - if (bkvhead[i])
> > - kfree(bkvhead[i]);
> > + kfree(bkvhead[i]);
> >
>
> Acked-by: Joel Fernandes (Google) <[email protected]>

Applied and pushed, thank you both!

Thanx, Paul

> thanks,
>
> - Joel
>
> > cond_resched_tasks_rcu_qs();
> > }