[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240828114704.mjzb3pxnjt45lt45@quack3>
Date: Wed, 28 Aug 2024 13:47:04 +0200
From: Jan Kara <jack@...e.cz>
To: Yu Jiaoliang <yujiaoliang@...o.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Seth Forshee <sforshee@...nel.org>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, opensource.kernel@...o.com
Subject: Re: [PATCH v2] mnt_idmapping: Use kmemdup_array instead of kmemdup
for multiple allocation
On Fri 23-08-24 09:55:41, Yu Jiaoliang wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
>
> v2:Add a new modification for reverse array.
>
> Signed-off-by: Yu Jiaoliang <yujiaoliang@...o.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> fs/mnt_idmapping.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
> index 3c60f1eaca61..79491663dbc0 100644
> --- a/fs/mnt_idmapping.c
> +++ b/fs/mnt_idmapping.c
> @@ -228,15 +228,15 @@ static int copy_mnt_idmap(struct uid_gid_map *map_from,
> return 0;
> }
>
> - forward = kmemdup(map_from->forward,
> - nr_extents * sizeof(struct uid_gid_extent),
> - GFP_KERNEL_ACCOUNT);
> + forward = kmemdup_array(map_from->forward, nr_extents,
> + sizeof(struct uid_gid_extent),
> + GFP_KERNEL_ACCOUNT);
> if (!forward)
> return -ENOMEM;
>
> - reverse = kmemdup(map_from->reverse,
> - nr_extents * sizeof(struct uid_gid_extent),
> - GFP_KERNEL_ACCOUNT);
> + reverse = kmemdup_array(map_from->reverse, nr_extents,
> + sizeof(struct uid_gid_extent),
> + GFP_KERNEL_ACCOUNT);
> if (!reverse) {
> kfree(forward);
> return -ENOMEM;
> --
> 2.34.1
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists