Skip to content

Commit 13cf06d

Browse files
hcahcaAlexander Gordeev
authored and
Alexander Gordeev
committed
s390/zcrypt: use kvmalloc_array() instead of kzalloc()
zcrypt_unlocked_ioctl() allocates 256k with kzalloc() which is likely to fail if memory is fragmented. To avoid that use kvmalloc_array() instead, like it is done at several other places for the same reason. Reviewed-by: Harald Freudenberger <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent 0dd0bbc commit 13cf06d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/s390/crypto/zcrypt_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,14 +1668,16 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
16681668
size_t total_size = MAX_ZDEV_ENTRIES_EXT
16691669
* sizeof(struct zcrypt_device_status_ext);
16701670

1671-
device_status = kzalloc(total_size, GFP_KERNEL);
1671+
device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT,
1672+
sizeof(struct zcrypt_device_status_ext),
1673+
GFP_KERNEL);
16721674
if (!device_status)
16731675
return -ENOMEM;
16741676
zcrypt_device_status_mask_ext(device_status);
16751677
if (copy_to_user((char __user *)arg, device_status,
16761678
total_size))
16771679
rc = -EFAULT;
1678-
kfree(device_status);
1680+
kvfree(device_status);
16791681
return rc;
16801682
}
16811683
case ZCRYPT_STATUS_MASK: {

0 commit comments

Comments
 (0)