Skip to contentSkip to conversation

aio: checking for NULL instead of IS_ERR

PATCH Applied Dan Carpenter 3 participants 3 messages Nov 13, 2013

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

PATCH 1/1 aio: checking for NULL instead of IS_ERR

alloc_anon_inode() returns an ERR_PTR(), it doesn't return NULL.

Fixes 71ad7490c1f3 ('rework aio migrate pages to use aio fs')
fs/aio.c +2 -2
index bf8d080..699f53e 100644
@@ -164,8 +164,8 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
 	struct file *file;
 	struct path path;
 	struct inode *inode = alloc_anon_inode(aio_mnt->mnt_sb);
-	if (!inode)
-		return ERR_PTR(-ENOMEM);
+	if (IS_ERR(inode))
+		return ERR_CAST(inode);
 
 	inode->i_mapping->a_ops = &aio_ctx_aops;
 	inode->i_mapping->private_data = ctx;
maintainer Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

alloc_anon_inode() returns an ERR_PTR(), it doesn't return NULL.

Fixes 71ad7490c1f3 ('rework aio migrate pages to use aio fs')

Applied.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

alloc_anon_inode() returns an ERR_PTR(), it doesn't return NULL.

Fixes 71ad7490c1f3 ('rework aio migrate pages to use aio fs')

Thanks for spotting this.

-ben

Quoted 15 lines
fs/aio.c +2 -2
index bf8d080..699f53e 100644
@@ -164,8 +164,8 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
 	struct file *file;
 	struct path path;
 	struct inode *inode = alloc_anon_inode(aio_mnt->mnt_sb);
-	if (!inode)
-		return ERR_PTR(-ENOMEM);
+	if (IS_ERR(inode))
+		return ERR_CAST(inode);
 
 	inode->i_mapping->a_ops = &aio_ctx_aops;
 	inode->i_mapping->private_data = ctx;
Signature · 1 line
"Thought is the essence of where you are now."