BACKPORT: Smack: freeing an error pointer in smk_write_revoke_subj()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 11 Jun 2015 08:51:16 +0000 (11:51 +0300)
committerRafal Krypa <r.krypa@samsung.com>
Mon, 21 Nov 2016 16:02:03 +0000 (17:02 +0100)
commit3719a3760ec5051ebafa00225459d107a24240c2
treebb3367aa44e519e3d5ce974ffa4ce63f9f667533
parent084c066c84c947aebea8e25572f4c50e783555ec
BACKPORT: Smack: freeing an error pointer in smk_write_revoke_subj()

This code used to rely on the fact that kfree(NULL) was a no-op, but
then we changed smk_parse_smack() to return error pointers on failure
instead of NULL.  Calling kfree() on an error pointer will oops.

I have re-arranged things a bit so that we only free things if they
have been allocated.

Fixes: e774ad683f42 ('smack: pass error code through pointers')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
(cherry-picked from upstream 5430209497eeb01415c681aaac0d00f65d24a526)
security/smack/smackfs.c