> This is dangerous, because the value of i doesn't tell you where exactly it failed. Instead you could loop through the entire funcs array, checking for funcs[i] to see if a kfree is needed and funcs[i]->patch to see if a kobject_put is needed.

Ops, I stuffed so many things here. 

> To clarify, I guess the kfree would only be needed if funcs[i] != NULL and funcs[i]->patch == NULL?

Maybe kobject_put could handle them all.
We registered the kobject release callback function, it will call kfree(), so we just only call kobject_put() instead of kfree() explicitly.

IMHO we could only check funcs[i] != NULL, then call kobject_put to release kobj.
```
err_sysfs2:
	for (i = 0; i < kpmod.patches_nr; i++) {
		if (funcs[i] != NULL)
			kobject_put(&funcs[i]->kobj);
	}
```

For those patch_func_alloc() failed `func`s, it doesn't exist in funcs, and do not kfree() it by kobject_put().
For those kobject_add() `func`s, it is allocated and exists in funcs, and it need to kobject_put() whatever adding success or fail.