Re: [PATCH RESEND -next] selinux: Let the caller free the momory in *mnt_opts on error

From: Paul Moore
Date: Mon Jun 20 2022 - 21:22:20 EST


On Fri, Jun 17, 2022 at 5:46 AM Xiu Jianfeng <xiujianfeng@xxxxxxxxxx> wrote:
>
> It may allocate memory for @mnt_opts if NULL in selinux_add_opt(), and
> now some error paths goto @err label to free memory while others don't,
> as suggested by Paul, don't free memory in case of error and let the
> caller to cleanup on error.
>
> And also this patch changes the @s NULL check to return -EINVAL instead.
>
> Link: https://lore.kernel.org/lkml/20220611090550.135674-1-xiujianfeng@xxxxxxxxxx/T/
> Suggested-by: Paul Moore <paul@xxxxxxxxxxxxxx>
> Signed-off-by: Xiu Jianfeng <xiujianfeng@xxxxxxxxxx>
> ---
> security/selinux/hooks.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)

Thanks, merged into selinux/next with some rewording of the subject
line and commit description.

--
paul-moore.com