diff mbox series

[V2,4/5] ubi: Reserve sufficient buffer length for the input mask

Message ID 20230718085119.3885747-5-wangzhaolong1@huawei.com
State Superseded
Headers show
Series ubi: Enhanced fault injection capability for the UBI driver | expand

Commit Message

ZhaoLong Wang July 18, 2023, 8:51 a.m. UTC
Because the mask received by the emulate_failures interface
is a 32-bit unsigned integer, ensure that there is sufficient
buffer length to receive and display this value.

Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
---
V2:
  - A 16-byte buffer is reserved, as implemented by other interfaces.

 drivers/mtd/ubi/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Zhihao Cheng July 31, 2023, 12:13 p.m. UTC | #1
在 2023/7/18 16:51, ZhaoLong Wang 写道:
> Because the mask received by the emulate_failures interface
> is a 32-bit unsigned integer, ensure that there is sufficient
> buffer length to receive and display this value.
> 
> Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
> ---
> V2:
>    - A 16-byte buffer is reserved, as implemented by other interfaces.
> 
>   drivers/mtd/ubi/debug.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
> index 016a861c5029..1c3f1a2436e5 100644
> --- a/drivers/mtd/ubi/debug.c
> +++ b/drivers/mtd/ubi/debug.c
> @@ -332,7 +332,7 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
>   	struct dentry *dent = file->f_path.dentry;
>   	struct ubi_device *ubi;
>   	struct ubi_debug_info *d;
> -	char buf[8];
> +	char buf[16];
>   	int val;
>   
>   	ubi = ubi_get_device(ubi_num);
> @@ -400,7 +400,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
>   	struct ubi_device *ubi;
>   	struct ubi_debug_info *d;
>   	size_t buf_size;
> -	char buf[8] = {0};
> +	char buf[16] = {0};
>   	int val;
>   
>   	ubi = ubi_get_device(ubi_num);
> 


Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
diff mbox series

Patch

diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 016a861c5029..1c3f1a2436e5 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -332,7 +332,7 @@  static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 	struct dentry *dent = file->f_path.dentry;
 	struct ubi_device *ubi;
 	struct ubi_debug_info *d;
-	char buf[8];
+	char buf[16];
 	int val;
 
 	ubi = ubi_get_device(ubi_num);
@@ -400,7 +400,7 @@  static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
 	struct ubi_device *ubi;
 	struct ubi_debug_info *d;
 	size_t buf_size;
-	char buf[8] = {0};
+	char buf[16] = {0};
 	int val;
 
 	ubi = ubi_get_device(ubi_num);