I'm not clear on why this exists as a separate function; it's just doing an equality check and then adding the grant?
But either way, a function whose functional name is "check_perm" can't be calling a function which adds a perm; it needs a new name. (And this whole string of them should get some docs.)