Skip to content

Commit

Permalink
s390/zcrypt: don't leak memory if dev_set_name() fails
Browse files Browse the repository at this point in the history
[ Upstream commit 6252f47 ]

When dev_set_name() fails, zcdn_create() doesn't free the newly
allocated resources. Do it.

Fixes: 00fab23 ("s390/zcrypt: multiple zcrypt device nodes support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230831110000.24279-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
andy-shev authored and gregkh committed Sep 19, 2023
1 parent 2a86ad7 commit 174f11e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/s390/crypto/zcrypt_api.c
Expand Up @@ -413,6 +413,7 @@ static int zcdn_create(const char *name)
ZCRYPT_NAME "_%d", (int)MINOR(devt));
nodename[sizeof(nodename) - 1] = '\0';
if (dev_set_name(&zcdndev->device, nodename)) {
kfree(zcdndev);
rc = -EINVAL;
goto unlockout;
}
Expand Down

0 comments on commit 174f11e

Please sign in to comment.