Re: [PATCH] security: keyring: remove redundant NULL check

From: David Howells
Date: Tue Jan 25 2011 - 09:35:51 EST


Davidlohr Bueso <dave@xxxxxxx> wrote:

> - if (prealloc) {
> - kfree(prealloc);
> - key_payload_reserve(keyring,
> - keyring->datalen - KEYQUOTA_LINK_BYTES);
> - }
> + kfree(prealloc);
> + key_payload_reserve(keyring,
> + keyring->datalen - KEYQUOTA_LINK_BYTES);
> +

This is not correct, since you'd be removing the quota allocation for the new
link in the case that __key_link() was called (and cleared *_prealloc).

However, the upstream code isn't correct either, since the preallocation may
not have extended the reservation at all (if it decided to displace a key
rather than adding a key).

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/