* [PATCH] ext4: direct return when jinode allocate failed in ext4_inode_attach_jinode
@ 2018-10-14 16:05 liusong
0 siblings, 0 replies; only message in thread
From: liusong @ 2018-10-14 16:05 UTC (permalink / raw)
To: tytso, adilger.kernel; +Cc: liu.song11, linux-ext4, linux-kernel
From: Liu Song <liu.song11@zte.com.cn>
Allocating memory for jinode do not need protected by *i_lock*.
Should return directly if memory allocation fails without holding
a spinlock.
Signed-off-by: Liu Song <liu.song11@zte.com.cn>
---
fs/ext4/inode.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d0dd585add6a..341d84521d11 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4382,12 +4382,11 @@ int ext4_inode_attach_jinode(struct inode *inode)
return 0;
jinode = jbd2_alloc_inode(GFP_KERNEL);
+ if (!jinode)
+ return -ENOMEM;
+
spin_lock(&inode->i_lock);
if (!ei->jinode) {
- if (!jinode) {
- spin_unlock(&inode->i_lock);
- return -ENOMEM;
- }
ei->jinode = jinode;
jbd2_journal_init_jbd_inode(ei->jinode, inode);
jinode = NULL;
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-10-14 16:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-14 16:05 [PATCH] ext4: direct return when jinode allocate failed in ext4_inode_attach_jinode liusong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).