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.