Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
0702e4f3
Commit
0702e4f3
authored
Feb 18, 2020
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dlmfs: convert dlmfs_file_read() to copy_to_user()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
3d3185ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
fs/ocfs2/dlmfs/dlmfs.c
fs/ocfs2/dlmfs/dlmfs.c
+14
-19
No files found.
fs/ocfs2/dlmfs/dlmfs.c
View file @
0702e4f3
...
@@ -227,7 +227,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
...
@@ -227,7 +227,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
loff_t
*
ppos
)
loff_t
*
ppos
)
{
{
int
bytes_left
;
int
bytes_left
;
ssize_t
readlen
,
got
;
ssize_t
got
;
char
*
lvb_buf
;
char
*
lvb_buf
;
struct
inode
*
inode
=
file_inode
(
filp
);
struct
inode
*
inode
=
file_inode
(
filp
);
...
@@ -237,36 +237,31 @@ static ssize_t dlmfs_file_read(struct file *filp,
...
@@ -237,36 +237,31 @@ static ssize_t dlmfs_file_read(struct file *filp,
if
(
*
ppos
>=
i_size_read
(
inode
))
if
(
*
ppos
>=
i_size_read
(
inode
))
return
0
;
return
0
;
/* don't read past the lvb */
if
(
count
>
i_size_read
(
inode
)
-
*
ppos
)
count
=
i_size_read
(
inode
)
-
*
ppos
;
if
(
!
count
)
if
(
!
count
)
return
0
;
return
0
;
if
(
!
access_ok
(
buf
,
count
))
lvb_buf
=
kmalloc
(
count
,
GFP_NOFS
);
return
-
EFAULT
;
/* don't read past the lvb */
if
((
count
+
*
ppos
)
>
i_size_read
(
inode
))
readlen
=
i_size_read
(
inode
)
-
*
ppos
;
else
readlen
=
count
;
lvb_buf
=
kmalloc
(
readlen
,
GFP_NOFS
);
if
(
!
lvb_buf
)
if
(
!
lvb_buf
)
return
-
ENOMEM
;
return
-
ENOMEM
;
got
=
user_dlm_read_lvb
(
inode
,
lvb_buf
,
readlen
);
got
=
user_dlm_read_lvb
(
inode
,
lvb_buf
,
count
);
if
(
got
)
{
if
(
got
)
{
BUG_ON
(
got
!=
readlen
);
BUG_ON
(
got
!=
count
);
bytes_left
=
__copy_to_user
(
buf
,
lvb_buf
,
readlen
);
bytes_left
=
copy_to_user
(
buf
,
lvb_buf
,
count
);
readlen
-=
bytes_left
;
count
-=
bytes_left
;
}
else
}
else
readlen
=
0
;
count
=
0
;
kfree
(
lvb_buf
);
kfree
(
lvb_buf
);
*
ppos
=
*
ppos
+
readlen
;
*
ppos
=
*
ppos
+
count
;
mlog
(
0
,
"read %z
d bytes
\n
"
,
readlen
);
mlog
(
0
,
"read %z
u bytes
\n
"
,
count
);
return
readlen
;
return
count
;
}
}
static
ssize_t
dlmfs_file_write
(
struct
file
*
filp
,
static
ssize_t
dlmfs_file_write
(
struct
file
*
filp
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment