Re: klp: make object/func-walking helpers more robust

From: Jiri Kosina
Date: Fri Apr 29 2016 - 04:35:38 EST


On Thu, 28 Apr 2016, Jessica Yu wrote:

> > #define klp_for_each_object(patch, obj) \
> > - for (obj = patch->objs; obj->funcs; obj++)
> > + for (obj = patch->objs; obj->funcs || obj->name; obj++)
>
> Remember that for patches to vmlinux, obj->name and obj->mod will also
> both be NULL. So if someone happens to forget to fill in obj->funcs
> for a vmlinux patch, we won't catch that case here. Perhaps we need a
> better way of determining whether we've reached the end of the array,
> or determining that the struct is truly empty..

I'd rather not over-compilcate it.

Admittedly, the change in the termination condition catches most of the
errors made by the patch author, but not all.
But there are many other places in the kernel where inserting an empty
item into the middle of statically initialized array will make the whole
thing explode, so let's not try to be more clever than necessary.

I plan to queue Miroslav's patch unless there are serious objections
raised.

Thanks,

--
Jiri Kosina
SUSE Labs