diff mbox series

[10/21] ext4: Remove unnecessary release when memory allocation failed in ext4_mb_init_cache

Message ID 20230209194825.511043-11-shikemeng@huaweicloud.com
State Not Applicable
Headers show
Series Some bugfix and cleanup to mballoc | expand

Commit Message

Kemeng Shi Feb. 9, 2023, 7:48 p.m. UTC
If we alloc array of buffer_head failed, there is no resource need to be
freed and we can simpily return error.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/ext4/mballoc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Ojaswin Mujoo Feb. 13, 2023, 7:48 p.m. UTC | #1
On Fri, Feb 10, 2023 at 03:48:14AM +0800, Kemeng Shi wrote:
> If we alloc array of buffer_head failed, there is no resource need to be
> freed and we can simpily return error.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/mballoc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index ad9e3b7d3198..15fc7105becc 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1168,10 +1168,8 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
>  	if (groups_per_page > 1) {
>  		i = sizeof(struct buffer_head *) * groups_per_page;
>  		bh = kzalloc(i, gfp);
> -		if (bh == NULL) {
> -			err = -ENOMEM;
> -			goto out;
> -		}
> +		if (bh == NULL)
> +			return -ENOMEM;
>  	} else
>  		bh = &bhs;
>  
> -- 
> 2.30.0
> 
Feel free to add:

Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
diff mbox series

Patch

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index ad9e3b7d3198..15fc7105becc 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1168,10 +1168,8 @@  static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
 	if (groups_per_page > 1) {
 		i = sizeof(struct buffer_head *) * groups_per_page;
 		bh = kzalloc(i, gfp);
-		if (bh == NULL) {
-			err = -ENOMEM;
-			goto out;
-		}
+		if (bh == NULL)
+			return -ENOMEM;
 	} else
 		bh = &bhs;