Re: [PATCH bpf-next] bpf: support raw tracepoints in modules

From: kbuild test robot
Date: Fri Nov 16 2018 - 16:55:32 EST


Hi Matt,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]

url: https://github.com/0day-ci/linux/commits/Matt-Mullins/bpf-support-raw-tracepoints-in-modules/20181110-144839
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master

smatch warnings:
kernel/trace/bpf_trace.c:1284 bpf_event_notify() error: potential null dereference 'btm'. (kzalloc returns null)

vim +/btm +1284 kernel/trace/bpf_trace.c

1269
1270 #ifdef CONFIG_MODULES
1271 int bpf_event_notify(struct notifier_block *nb, unsigned long op, void *module)
1272 {
1273 struct bpf_trace_module *btm, *tmp;
1274 struct module *mod = module;
1275
1276 if (mod->num_bpf_raw_events == 0)
1277 return 0;
1278
1279 mutex_lock(&bpf_module_mutex);
1280
1281 switch (op) {
1282 case MODULE_STATE_COMING:
1283 btm = kzalloc(sizeof(*btm), GFP_KERNEL);
> 1284 btm->module = module;
1285 list_add(&btm->list, &bpf_trace_modules);
1286 break;
1287 case MODULE_STATE_GOING:
1288 list_for_each_entry_safe(btm, tmp, &bpf_trace_modules, list) {
1289 if (btm->module == module) {
1290 list_del(&btm->list);
1291 kfree(btm);
1292 break;
1293 }
1294 }
1295 break;
1296 }
1297
1298 mutex_unlock(&bpf_module_mutex);
1299
1300 return 0;
1301 }
1302

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation