2015-02-11 09:27:02

by Bas Peters

[permalink] [raw]
Subject: [PATCH] fs: dlm: lockspace.c: removal of unnecessary check before calling kfree()

kfree() checks its argument. It is therefore unnecessary to do this
twice.

This issue was detected using Coccinelle.

Signed-off-by: Bas Peters <[email protected]>
---
fs/dlm/lockspace.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index f3e7278..b660b93 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -674,8 +674,7 @@ static int new_lockspace(const char *name, const char *cluster,
out_lkbidr:
idr_destroy(&ls->ls_lkbidr);
for (i = 0; i < DLM_REMOVE_NAMES_MAX; i++) {
- if (ls->ls_remove_names[i])
- kfree(ls->ls_remove_names[i]);
+ kfree(ls->ls_remove_names[i]);
}
out_rsbtbl:
vfree(ls->ls_rsbtbl);
--
2.1.0


2015-02-11 12:10:52

by SF Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH] fs: dlm: lockspace.c: removal of unnecessary check before calling kfree()

> kfree() checks its argument. It is therefore unnecessary to do this twice.
>
> This issue was detected using Coccinelle.

Would you like to integrate my update suggestion 'fs-DLM: Deletion of
unnecessary checks before the function call "kfree"'?
https://lkml.org/lkml/2014/11/29/88
http://article.gmane.org/gmane.linux.kernel/1840524
https://www.mail-archive.com/[email protected]/msg778279.html

Regards,
Markus

2015-02-11 12:13:00

by Bas Peters

[permalink] [raw]
Subject: Re: [PATCH] fs: dlm: lockspace.c: removal of unnecessary check before calling kfree()

2015-02-11 13:10 GMT+01:00 SF Markus Elfring <[email protected]>:
>> kfree() checks its argument. It is therefore unnecessary to do this twice.
>>
>> This issue was detected using Coccinelle.
>
> Would you like to integrate my update suggestion 'fs-DLM: Deletion of
> unnecessary checks before the function call "kfree"'?
> https://lkml.org/lkml/2014/11/29/88
> http://article.gmane.org/gmane.linux.kernel/1840524
> https://www.mail-archive.com/[email protected]/msg778279.html

I'll drop that too :)

> Regards,
> Markus
>

2015-02-11 12:21:01

by SF Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH] fs: dlm: lockspace.c: removal of unnecessary check before calling kfree()

>> https://lkml.org/lkml/2014/11/29/88
>> http://article.gmane.org/gmane.linux.kernel/1840524
>> https://www.mail-archive.com/[email protected]/msg778279.html
>
> I'll drop that too :)

Would you like to add any tags to my update suggestion?

Are you looking for more opportunities around clean-up of such safety checks
in Linux source code?

Regards,
Markus