Skip to contentSkip to conversation

autofs4: autofs4_catatonic_mode(): remove redundant null check on kfree()

PATCH In review Tim Gardner 3 participants 5 messages Feb 12, 2013 – Feb 13, 2013 Kernel automounter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 autofs4: autofs4_catatonic_mode(): remove redundant null check on kfree()

smatch analysis:

fs/autofs4/waitq.c:46 autofs4_catatonic_mode() info: redundant null
check on wq->name.name calling kfree()

---
 fs/autofs4/waitq.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/autofs4/waitq.c +2 -4
index 03bc1d3..3db70da 100644
@@ -42,10 +42,8 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
 	while (wq) {
 		nwq = wq->next;
 		wq->status = -ENOENT; /* Magic is gone - report failure */
-		if (wq->name.name) {
-			kfree(wq->name.name);
-			wq->name.name = NULL;
-		}
+		kfree(wq->name.name);
+		wq->name.name = NULL;
 		wq->wait_ctr--;
 		wake_up_interruptible(&wq->queue);
 		wq = nwq;
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 4 lines · Tim Gardner

smatch analysis:

fs/autofs4/waitq.c:46 autofs4_catatonic_mode() info: redundant null
check on wq->name.name calling kfree()

I'm not sure about this change.

autofs4_catatonic_mode() could be called when there are remaining entries in the wait queue, which is nulled, so autofs4_wait_release() won't see the the discarded waits if it is called.

Quoted 25 lines
---
 fs/autofs4/waitq.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/autofs4/waitq.c +2 -4
index 03bc1d3..3db70da 100644
@@ -42,10 +42,8 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
 	while (wq) {
 		nwq = wq->next;
 		wq->status = -ENOENT; /* Magic is gone - report failure */
-		if (wq->name.name) {
-			kfree(wq->name.name);
-			wq->name.name = NULL;
-		}
+		kfree(wq->name.name);
+		wq->name.name = NULL;
 		wq->wait_ctr--;
 		wake_up_interruptible(&wq->queue);
 		wq = nwq;
#2 lore raw
Quoted 11 lines · Ian Kent
Quoted 4 lines · Tim Gardner

smatch analysis:

fs/autofs4/waitq.c:46 autofs4_catatonic_mode() info: redundant null
check on wq->name.name calling kfree()

I'm not sure about this change.

autofs4_catatonic_mode() could be called when there are remaining entries in the wait queue, which is nulled, so autofs4_wait_release() won't see the the discarded waits if it is called.

Ian, this is about something else really. The patch is about the NULL check before calling kfree() -- it does the NULL check internally. It is nothing about code flow or anything else, it is about calling kfree() unconditionally regardless whenever the argument is actually NULL or non-NULL. It makes the code shorter and easier to read.

You can add my

if you want.

Quoted 31 lines
Quoted 14 lines
---
  fs/autofs4/waitq.c |    6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
fs/autofs4/waitq.c +0 -0
index 03bc1d3..3db70da 100644
@@ -42,10 +42,8 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
  	while (wq) {
  		nwq = wq->next;

fs/autofs4/waitq.c void autofs4_catatonic_mode(struct autofs_sb_info *sbi) · line 49

Quoted 10 lines
fs/autofs4/waitq.c +2 -4
  		wq->status = -ENOENT; /* Magic is gone - report failure */
-		if (wq->name.name) {
-			kfree(wq->name.name);
-			wq->name.name = NULL;
-		}
+		kfree(wq->name.name);
+		wq->name.name = NULL;
  		wq->wait_ctr--;
  		wake_up_interruptible(&wq->queue);
  		wq = nwq;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw
Quoted 13 lines · Michael Tokarev
Quoted 11 lines · Ian Kent
Quoted 4 lines · Tim Gardner

smatch analysis:

fs/autofs4/waitq.c:46 autofs4_catatonic_mode() info: redundant null
check on wq->name.name calling kfree()

I'm not sure about this change.

autofs4_catatonic_mode() could be called when there are remaining entries in the wait queue, which is nulled, so autofs4_wait_release() won't see the the discarded waits if it is called.

Quoted 5 lines

Ian, this is about something else really. The patch is about the NULL check before calling kfree() -- it does the NULL check internally. It is nothing about code flow or anything else, it is about calling kfree() unconditionally regardless whenever the argument is actually NULL or non-NULL. It makes the code shorter and easier to read.

Oh, right, kfree() does the a NULL check since a long time now. My bad, sorry.

Quoted 4 lines

You can add my

So, you would like me to forward this to Linus?

I'd be inclined to wait until the window for 3.9 opens since Linus probably has more than enough to do finalizing 3.8 right now.

Ian

#4 lore raw

13.02.2013 11:37, Ian Kent wrote:
[]

Quoted 4 lines

So, you would like me to forward this to Linus?

I'd be inclined to wait until the window for 3.9 opens since Linus probably has more than enough to do finalizing 3.8 right now.

I guess this change is anything but urgent ;)

Thanks,

/mjt