linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext2: return error when fail to allocating memory in ioctl
@ 2019-10-23 13:56 Chengguang Xu
  2019-10-24  7:24 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Chengguang Xu @ 2019-10-23 13:56 UTC (permalink / raw)
  To: jack; +Cc: linux-ext4, Chengguang Xu

Currently, we do not check memory allocation
result for ei->i_block_alloc_info in ioctl,
this patch checks it and returns error in
failure case.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/ext2/ioctl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 1b853fb0b163..32a8d10b579d 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -145,10 +145,13 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		if (ei->i_block_alloc_info){
 			struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
 			rsv->rsv_goal_size = rsv_window_size;
+		} else {
+			ret = -ENOMEM;
 		}
+
 		mutex_unlock(&ei->truncate_mutex);
 		mnt_drop_write_file(filp);
-		return 0;
+		return ret;
 	}
 	default:
 		return -ENOTTY;
-- 
2.21.0




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

* Re: [PATCH] ext2: return error when fail to allocating memory in ioctl
  2019-10-23 13:56 [PATCH] ext2: return error when fail to allocating memory in ioctl Chengguang Xu
@ 2019-10-24  7:24 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-10-24  7:24 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: jack, linux-ext4

On Wed 23-10-19 21:56:43, Chengguang Xu wrote:
> Currently, we do not check memory allocation
> result for ei->i_block_alloc_info in ioctl,
> this patch checks it and returns error in
> failure case.
> 
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>

Makes sense. Applied. Thanks!

							Honza

> ---
>  fs/ext2/ioctl.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
> index 1b853fb0b163..32a8d10b579d 100644
> --- a/fs/ext2/ioctl.c
> +++ b/fs/ext2/ioctl.c
> @@ -145,10 +145,13 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  		if (ei->i_block_alloc_info){
>  			struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
>  			rsv->rsv_goal_size = rsv_window_size;
> +		} else {
> +			ret = -ENOMEM;
>  		}
> +
>  		mutex_unlock(&ei->truncate_mutex);
>  		mnt_drop_write_file(filp);
> -		return 0;
> +		return ret;
>  	}
>  	default:
>  		return -ENOTTY;
> -- 
> 2.21.0
> 
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2019-10-24  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 13:56 [PATCH] ext2: return error when fail to allocating memory in ioctl Chengguang Xu
2019-10-24  7:24 ` Jan Kara

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).