On Mon, Dec 23, 2019 at 11:54:17AM -0800, Andrii Nakryiko wrote: > > - for (i = 0; i < obj->nr_maps; i++) > > + for (i = 0; i < obj->nr_maps; i++) { > > zclose(obj->maps[i].fd); > > + if (obj->maps[i].st_ops) > > + zfree(&obj->maps[i].st_ops->kern_vdata); > > any specific reason to deallocate only kern_vdata? maybe just > consolidate all the clean up in bpf_object__close instead? I think it is the same as why the map fd is closed here. kern_vdata is allocated at load time, so it seems more logical to me to deallocate asap at unload time. For example, if user calls bpf_object__load_xattr() and one of the load steps fails, bpf_object__unload (but not bpf_object__close) is called before returning.