mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
s390/zcrypt: utilize dev_set_name() ability to use a formatted string
With the dev_set_name() prototype it's not obvious that it takes a formatted string as a parameter. Use its facility instead of duplicating the same with strncpy()/snprintf() calls. With this, also prevent return error code to be shadowed. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230831110000.24279-2-andriy.shevchenko@linux.intel.com Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
committed by
Heiko Carstens
parent
6252f47b78
commit
f59ec04d38
@@ -366,7 +366,6 @@ static int zcdn_create(const char *name)
|
||||
{
|
||||
dev_t devt;
|
||||
int i, rc = 0;
|
||||
char nodename[ZCDN_MAX_NAME];
|
||||
struct zcdn_device *zcdndev;
|
||||
|
||||
if (mutex_lock_interruptible(&ap_perms_mutex))
|
||||
@@ -407,14 +406,11 @@ static int zcdn_create(const char *name)
|
||||
zcdndev->device.devt = devt;
|
||||
zcdndev->device.groups = zcdn_dev_attr_groups;
|
||||
if (name[0])
|
||||
strncpy(nodename, name, sizeof(nodename));
|
||||
rc = dev_set_name(&zcdndev->device, "%s", name);
|
||||
else
|
||||
snprintf(nodename, sizeof(nodename),
|
||||
ZCRYPT_NAME "_%d", (int)MINOR(devt));
|
||||
nodename[sizeof(nodename) - 1] = '\0';
|
||||
if (dev_set_name(&zcdndev->device, nodename)) {
|
||||
rc = dev_set_name(&zcdndev->device, ZCRYPT_NAME "_%d", (int)MINOR(devt));
|
||||
if (rc) {
|
||||
kfree(zcdndev);
|
||||
rc = -EINVAL;
|
||||
goto unlockout;
|
||||
}
|
||||
rc = device_register(&zcdndev->device);
|
||||
|
||||
Reference in New Issue
Block a user