[PATCH] Keys: Fix key quota management on key allocation

Make key quota detection generate an error if either quota is exceeded rather
than only if both quotas are exceeded.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
David Howells 2006-03-25 03:06:51 -08:00 committed by Linus Torvalds
parent a7d06ca7b6
commit 3dccff8dc0

View file

@ -1,6 +1,6 @@
/* key.c: basic authentication token and access key management /* key.c: basic authentication token and access key management
* *
* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Copyright (C) 2004-6 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com) * Written by David Howells (dhowells@redhat.com)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -271,7 +271,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
* its description */ * its description */
if (!not_in_quota) { if (!not_in_quota) {
spin_lock(&user->lock); spin_lock(&user->lock);
if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS && if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS ||
user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES
) )
goto no_quota; goto no_quota;