This function could be simplified by moving the kmem_alloc() after the proc_mkdir().  Then we wouldn't need to free the just allocated memory in the error case.