]> git.baikalelectronics.ru Git - kernel.git/commit
selinux: selinux_add_opt() callers free memory
authorXiu Jianfeng <xiujianfeng@huawei.com>
Fri, 17 Jun 2022 09:44:12 +0000 (17:44 +0800)
committerPaul Moore <paul@paul-moore.com>
Tue, 21 Jun 2022 01:05:40 +0000 (21:05 -0400)
commit511e5ad5741102232f1a3c4f2f203cf150518470
tree5e92d231c0ecd7331cec51bfa272edc7c8f06e31
parentfa7750a1a12f3218d5961a56f9fac3e8f3134449
selinux: selinux_add_opt() callers free memory

The selinux_add_opt() function may need to allocate memory for the
mount options if none has already been allocated, but there is no
need to free that memory on error as the callers handle that.  Drop
the existing kfree() on error to help increase consistency in the
selinux_add_opt() error handling.

This patch also changes selinux_add_opt() to return -EINVAL when
the mount option value, @s, is NULL.  It currently return -ENOMEM.

Link: https://lore.kernel.org/lkml/20220611090550.135674-1-xiujianfeng@huawei.com/T/
Suggested-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
[PM: fix subject, rework commit description language]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c