apparmor: guard against free routines being called with a NULL

aa_free_data() and free_attachment() don't guard against having
a NULL parameter passed to them. Fix this.

Reviewed-by: Ryan Lee <ryan.lee@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2025-08-03 22:07:52 -07:00
parent 74b7105e53
commit e16eee7895

View file

@ -232,6 +232,9 @@ static void aa_free_data(void *ptr, void *arg)
{
struct aa_data *data = ptr;
if (!ptr)
return;
kvfree_sensitive(data->data, data->size);
kfree_sensitive(data->key);
kfree_sensitive(data);
@ -241,6 +244,9 @@ static void free_attachment(struct aa_attachment *attach)
{
int i;
if (!attach)
return;
for (i = 0; i < attach->xattr_count; i++)
kfree_sensitive(attach->xattrs[i]);
kfree_sensitive(attach->xattrs);