All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfs: get inode after passing previous check in rw_verify_area()
@ 2018-06-21 10:29 lorneli.cs
  2018-06-21 12:22 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: lorneli.cs @ 2018-06-21 10:29 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, Lorne Li

From: Lorne Li <lorneli.cs@gmail.com>

Move file_inode function to the front of line actually using inode.

Signed-off-by: Lorne Li <lorneli.cs@gmail.com>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 153f8f6..ab63e87 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -368,7 +368,6 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t
 	loff_t pos;
 	int retval = -EINVAL;
 
-	inode = file_inode(file);
 	if (unlikely((ssize_t) count < 0))
 		return retval;
 	pos = *ppos;
@@ -382,6 +381,7 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t
 			return retval;
 	}
 
+	inode = file_inode(file);
 	if (unlikely(inode->i_flctx && mandatory_lock(inode))) {
 		retval = locks_mandatory_area(inode, file, pos, pos + count - 1,
 				read_write == READ ? F_RDLCK : F_WRLCK);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vfs: get inode after passing previous check in rw_verify_area()
  2018-06-21 10:29 [PATCH] vfs: get inode after passing previous check in rw_verify_area() lorneli.cs
@ 2018-06-21 12:22 ` Christoph Hellwig
  2018-06-21 14:53   ` Lorne Li
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2018-06-21 12:22 UTC (permalink / raw)
  To: lorneli.cs; +Cc: viro, linux-fsdevel

On Thu, Jun 21, 2018 at 06:29:33PM +0800, lorneli.cs@gmail.com wrote:
> From: Lorne Li <lorneli.cs@gmail.com>
> 
> Move file_inode function to the front of line actually using inode.

Why?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vfs: get inode after passing previous check in rw_verify_area()
  2018-06-21 12:22 ` Christoph Hellwig
@ 2018-06-21 14:53   ` Lorne Li
  0 siblings, 0 replies; 3+ messages in thread
From: Lorne Li @ 2018-06-21 14:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: viro, linux-fsdevel

If previous check (pos and overflow check) fails, there's no chance to

use variable inode, initialized by file_inode func in the beginning.

So delay the operation until actuallyneeding inode for check.


Maybe I should add a more detailed commit message.


On 2018/6/21 20:22, Christoph Hellwig wrote:
> On Thu, Jun 21, 2018 at 06:29:33PM +0800, lorneli.cs@gmail.com wrote:
>> From: Lorne Li <lorneli.cs@gmail.com>
>>
>> Move file_inode function to the front of line actually using inode.
> Why?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-21 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-21 10:29 [PATCH] vfs: get inode after passing previous check in rw_verify_area() lorneli.cs
2018-06-21 12:22 ` Christoph Hellwig
2018-06-21 14:53   ` Lorne Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.