In register_fprobe(), get_ips_from_filter() resolves target function addresses and increments module reference counts via try_module_get() for symbols in kernel modules. If get_ips_from_filter() fails on the second pass and returns an error, register_fprobe() returned directly without releasing module references acquired up to that point. Fix this by ensuring the cleanup loop executing module_put() runs even when get_ips_from_filter() returns a negative error. Link: https://lore.kernel.org/all/178528125360.101985.4144133640239273153.stgit@devnote2/
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -961,10 +961,8 @@ int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter · 960 unmodified lines | |||
| 961 | return -ENOMEM; | 961 | return -ENOMEM; |
| 962 | 962 | ||
| 963 | ret = get_ips_from_filter(filter, notfilter, addrs, mods, num); | 963 | ret = get_ips_from_filter(filter, notfilter, addrs, mods, num); |
| 964 | if (ret < 0) | 964 | if (ret >= 0) |
| 965 | return ret; | 965 | ret = register_fprobe_ips(fp, addrs, ret); |
| 966 | |||
| 967 | ret = register_fprobe_ips(fp, addrs, ret); | ||
| 968 | 966 | ||
| 969 | for (int i = 0; i < num; i++) { | 967 | for (int i = 0; i < num; i++) { |
| 970 | if (mods[i]) | 968 | if (mods[i]) |