Skip to contentSkip to conversation

autofs4: redundant null check on kfree()

PATCH New Jiejing.Zhang 1 participant 2 messages Aug 11, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: JieJing.Zhang <[email protected]>

---
 fs/autofs4/inode.c |    6 ++----
 fs/autofs4/waitq.c |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
fs/autofs4/inode.c +2 -4
index 821b2b9..4e394ef 100644
@@ -24,10 +24,8 @@
 
 static void ino_lnkfree(struct autofs_info *ino)
 {
-	if (ino->u.symlink) {
-		kfree(ino->u.symlink);
-		ino->u.symlink = NULL;
-	}
+	kfree(ino->u.symlink);
+	ino->u.symlink = NULL;
 }
 
 struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
fs/autofs4/waitq.c +2 -4
index 2341375..cff98b0 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.0.4
#1 lore raw

PATCH 2/2 Btrfs: handle memory alloc failure in btrfs_file_aio_write()

From: JieJing.Zhang <[email protected]>

---
 fs/btrfs/file.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/btrfs/file.c +4 -0
index e354c33..caa9e3f 100644
@@ -926,6 +926,10 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
 		     PAGE_CACHE_SIZE, PAGE_CACHE_SIZE /
 		     (sizeof(struct page *)));
 	pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL);
+	if (unlikely(!pages)) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	/* generic_write_checks can change our pos */
 	start_pos = pos;
Signature · 1 line
1.7.0.4