Skip to contentSkip to conversation

perf/core: Introduce address range filtering

DISCUSSION Dan Carpenter 1 participant 2 messages May 10, 2016 – May 30, 2016 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hello Alexander Shishkin,

This is a semi-automatic email about new static checker warnings.

The patch 375637bc5249: "perf/core: Introduce address range filtering" from Apr 27, 2016, leads to the following Smatch complaint:

kernel/events/core.c:3865 _free_event()

	 warn: variable dereferenced before check 'event->pmu' (see line 3856)

kernel/events/core.c
3855 perf_event_free_bpf_prog(event);

  3856		perf_addr_filters_splice(event, NULL);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

New code adds an unchecked "event->pmu" dereference inside function.

3857 kfree(event->addr_filters_offs);
3858
3859 if (event->destroy)
3860 event->destroy(event);
3861
3862 if (event->ctx)
3863 put_ctx(event->ctx);
3864

  3865		if (event->pmu) {
                    ^^^^^^^^^^

Existing code assumes this can be NULL.

  3866			exclusive_event_destroy(event);
  3867			module_put(event->pmu->module);

regards,
dan carpenter

#1 lore raw

I was looking through old warnings and this is still present in current linux-next.

regards,
dan carpenter

Quoted 33 lines · Dan Carpenter

Hello Alexander Shishkin,

This is a semi-automatic email about new static checker warnings.

The patch 375637bc5249: "perf/core: Introduce address range filtering" from Apr 27, 2016, leads to the following Smatch complaint:

kernel/events/core.c:3865 _free_event()

	 warn: variable dereferenced before check 'event->pmu' (see line 3856)

kernel/events/core.c
3855 perf_event_free_bpf_prog(event);

  3856		perf_addr_filters_splice(event, NULL);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

New code adds an unchecked "event->pmu" dereference inside function.

3857 kfree(event->addr_filters_offs);
3858
3859 if (event->destroy)
3860 event->destroy(event);
3861
3862 if (event->ctx)
3863 put_ctx(event->ctx);
3864

  3865		if (event->pmu) {
                    ^^^^^^^^^^

Existing code assumes this can be NULL.

  3866			exclusive_event_destroy(event);
  3867			module_put(event->pmu->module);

regards,
dan carpenter