[PATCH v3 45/57] perf: Simplify perf_event_parse_addr_filter()
Kees Cook
keescook at chromium.org
Tue Jun 13 19:47:26 UTC 2023
On Mon, Jun 12, 2023 at 11:07:58AM +0200, Peter Zijlstra wrote:
> XXX this code needs a cleanup
:)
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
> ---
> kernel/events/core.c | 56 ++++++++++++++++++++-------------------------------
> 1 file changed, 22 insertions(+), 34 deletions(-)
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -10495,6 +10495,8 @@ static void free_filters_list(struct lis
> }
> }
>
> +DEFINE_FREE(filter_list, struct list_head *, if (_T) free_filters_list(_T))
> +
> /*
> * Free existing address filters and optionally install new ones
> */
> @@ -10658,13 +10660,15 @@ perf_event_parse_addr_filter(struct perf
> struct list_head *filters)
> {
> struct perf_addr_filter *filter = NULL;
> - char *start, *orig, *filename = NULL;
> substring_t args[MAX_OPT_ARGS];
> int state = IF_STATE_ACTION, token;
> unsigned int kernel = 0;
> - int ret = -EINVAL;
> + char *start;
> + int ret;
>
> - orig = fstr = kstrdup(fstr, GFP_KERNEL);
> + struct list_head *fguard __free(filter_list) = filters;
> + char *filename __free(kfree) = NULL;
> + char *orig __free(kfree) = fstr = kstrdup(fstr, GFP_KERNEL);
Ah! I see a kfree users. Sorry for the noise. :)
--
Kees Cook
More information about the Linux-security-module-archive
mailing list