mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
apparmor: Return directly after a failed kzalloc() in two functions
1. Return directly after a call of the function “kzalloc” failed at the beginning in these function implementations. 2. Omit extra initialisations (for a few local variables) which became unnecessary with this refactoring. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
committed by
John Johansen
parent
755a22c743
commit
6d7467957e
@@ -28,15 +28,15 @@ unsigned int aa_hash_size(void)
|
|||||||
char *aa_calc_hash(void *data, size_t len)
|
char *aa_calc_hash(void *data, size_t len)
|
||||||
{
|
{
|
||||||
SHASH_DESC_ON_STACK(desc, apparmor_tfm);
|
SHASH_DESC_ON_STACK(desc, apparmor_tfm);
|
||||||
char *hash = NULL;
|
char *hash;
|
||||||
int error = -ENOMEM;
|
int error;
|
||||||
|
|
||||||
if (!apparmor_tfm)
|
if (!apparmor_tfm)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hash = kzalloc(apparmor_hash_size, GFP_KERNEL);
|
hash = kzalloc(apparmor_hash_size, GFP_KERNEL);
|
||||||
if (!hash)
|
if (!hash)
|
||||||
goto fail;
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
desc->tfm = apparmor_tfm;
|
desc->tfm = apparmor_tfm;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
SHASH_DESC_ON_STACK(desc, apparmor_tfm);
|
SHASH_DESC_ON_STACK(desc, apparmor_tfm);
|
||||||
int error = -ENOMEM;
|
int error;
|
||||||
__le32 le32_version = cpu_to_le32(version);
|
__le32 le32_version = cpu_to_le32(version);
|
||||||
|
|
||||||
if (!aa_g_hash_policy)
|
if (!aa_g_hash_policy)
|
||||||
@@ -73,7 +73,7 @@ int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
|
|||||||
|
|
||||||
profile->hash = kzalloc(apparmor_hash_size, GFP_KERNEL);
|
profile->hash = kzalloc(apparmor_hash_size, GFP_KERNEL);
|
||||||
if (!profile->hash)
|
if (!profile->hash)
|
||||||
goto fail;
|
return -ENOMEM;
|
||||||
|
|
||||||
desc->tfm = apparmor_tfm;
|
desc->tfm = apparmor_tfm;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user