Skip to content

Commit c124863

Browse files
committed
s390/zcrypt: Use kvcalloc() instead of kvmalloc_array()
sparse warns about a large memset() call within zcrypt_device_status_mask_ext(): drivers/s390/crypto/zcrypt_api.c:1303:15: warning: memset with byte count of 262144 Get rid of this warning by making sure that all callers of this function allocate memory with __GFP_ZERO, which zeroes memory already at allocation time, which again allows to remove the memset() call. Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent d890e6a commit c124863

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

drivers/s390/crypto/zcrypt_api.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,9 +1300,6 @@ void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus)
13001300
struct zcrypt_device_status_ext *stat;
13011301
int card, queue;
13021302

1303-
memset(devstatus, 0, MAX_ZDEV_ENTRIES_EXT
1304-
* sizeof(struct zcrypt_device_status_ext));
1305-
13061303
spin_lock(&zcrypt_list_lock);
13071304
for_each_zcrypt_card(zc) {
13081305
for_each_zcrypt_queue(zq, zc) {
@@ -1607,9 +1604,9 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
16071604
size_t total_size = MAX_ZDEV_ENTRIES_EXT
16081605
* sizeof(struct zcrypt_device_status_ext);
16091606

1610-
device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT,
1611-
sizeof(struct zcrypt_device_status_ext),
1612-
GFP_KERNEL);
1607+
device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT,
1608+
sizeof(struct zcrypt_device_status_ext),
1609+
GFP_KERNEL);
16131610
if (!device_status)
16141611
return -ENOMEM;
16151612
zcrypt_device_status_mask_ext(device_status);

drivers/s390/crypto/zcrypt_ccamisc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,9 +1762,9 @@ static int findcard(u64 mkvp, u16 *pcardnr, u16 *pdomain,
17621762
return -EINVAL;
17631763

17641764
/* fetch status of all crypto cards */
1765-
device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT,
1766-
sizeof(struct zcrypt_device_status_ext),
1767-
GFP_KERNEL);
1765+
device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT,
1766+
sizeof(struct zcrypt_device_status_ext),
1767+
GFP_KERNEL);
17681768
if (!device_status)
17691769
return -ENOMEM;
17701770
zcrypt_device_status_mask_ext(device_status);
@@ -1878,9 +1878,9 @@ int cca_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain,
18781878
struct cca_info ci;
18791879

18801880
/* fetch status of all crypto cards */
1881-
device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT,
1882-
sizeof(struct zcrypt_device_status_ext),
1883-
GFP_KERNEL);
1881+
device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT,
1882+
sizeof(struct zcrypt_device_status_ext),
1883+
GFP_KERNEL);
18841884
if (!device_status)
18851885
return -ENOMEM;
18861886
zcrypt_device_status_mask_ext(device_status);

drivers/s390/crypto/zcrypt_ep11misc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,9 @@ int ep11_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain,
15881588
struct ep11_card_info eci;
15891589

15901590
/* fetch status of all crypto cards */
1591-
device_status = kvmalloc_array(MAX_ZDEV_ENTRIES_EXT,
1592-
sizeof(struct zcrypt_device_status_ext),
1593-
GFP_KERNEL);
1591+
device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT,
1592+
sizeof(struct zcrypt_device_status_ext),
1593+
GFP_KERNEL);
15941594
if (!device_status)
15951595
return -ENOMEM;
15961596
zcrypt_device_status_mask_ext(device_status);

0 commit comments

Comments
 (0)