Re: [PATCH 01/11] mem: remove duplicate ops for /dev/zero and /dev/null

2020-08-18 Thread Kees Cook
On Mon, Aug 17, 2020 at 09:32:02AM +0200, Christoph Hellwig wrote:
> There is no good reason to implement both the traditional ->read and
> ->write as well as the iter based ops.  So implement just the iter
> based ones.
> 
> Suggested-by: Al Viro 
> Signed-off-by: Christoph Hellwig 

Reviewed-by: Kees Cook 

-- 
Kees Cook


[PATCH 01/11] mem: remove duplicate ops for /dev/zero and /dev/null

2020-08-17 Thread Christoph Hellwig
There is no good reason to implement both the traditional ->read and
->write as well as the iter based ops.  So implement just the iter
based ones.

Suggested-by: Al Viro 
Signed-off-by: Christoph Hellwig 
---
 drivers/char/mem.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 687d4af6945d36..14851f36787372 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -670,18 +670,6 @@ static ssize_t write_port(struct file *file, const char 
__user *buf,
return tmp-buf;
 }
 
-static ssize_t read_null(struct file *file, char __user *buf,
-size_t count, loff_t *ppos)
-{
-   return 0;
-}
-
-static ssize_t write_null(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
-{
-   return count;
-}
-
 static ssize_t read_iter_null(struct kiocb *iocb, struct iov_iter *to)
 {
return 0;
@@ -872,7 +860,6 @@ static int open_port(struct inode *inode, struct file *filp)
 
 #define zero_lseek null_lseek
 #define full_lseek  null_lseek
-#define write_zero write_null
 #define write_iter_zerowrite_iter_null
 #define open_mem   open_port
 #define open_kmem  open_mem
@@ -903,8 +890,6 @@ static const struct file_operations __maybe_unused 
kmem_fops = {
 
 static const struct file_operations null_fops = {
.llseek = null_lseek,
-   .read   = read_null,
-   .write  = write_null,
.read_iter  = read_iter_null,
.write_iter = write_iter_null,
.splice_write   = splice_write_null,
@@ -919,7 +904,6 @@ static const struct file_operations __maybe_unused 
port_fops = {
 
 static const struct file_operations zero_fops = {
.llseek = zero_lseek,
-   .write  = write_zero,
.read_iter  = read_iter_zero,
.write_iter = write_iter_zero,
.mmap   = mmap_zero,
-- 
2.28.0