Skip to contentSkip to conversation

KVM: s390: pci: Fix allocation size of aift kzdev elements

PATCH In review Rafael Mendonca 4 participants 4 messages Oct 26, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: s390: pci: Fix allocation size of aift kzdev elements

The 'kzdev' field of struct 'zpci_aift' is an array of pointers to 'kvm_zdev' structs. Allocate the proper size accordingly.

Reported by Coccinelle:
WARNING: Use correct pointer type argument for sizeof

Fixes 98b1d33dac5f ("KVM: s390: pci: do initial setup for AEN interpretation")
---
 arch/s390/kvm/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/pci.c +1 -1
index c50c1645c0ae..ded1af2ddae9 100644
@@ -126,7 +126,7 @@ int kvm_s390_pci_aen_init(u8 nisc)
 		return -EPERM;
 
 	mutex_lock(&aift->aift_lock);
-	aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev),
+	aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev *),
 			      GFP_KERNEL);
 	if (!aift->kzdev) {
 		rc = -ENOMEM;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Rafael Mendonca

The 'kzdev' field of struct 'zpci_aift' is an array of pointers to 'kvm_zdev' structs. Allocate the proper size accordingly.

Reported by Coccinelle:
WARNING: Use correct pointer type argument for sizeof

Fixes 98b1d33dac5f ("KVM: s390: pci: do initial setup for AEN interpretation")

Thanks for reporting & fixing.

Quoted 17 lines
---
 arch/s390/kvm/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/pci.c +1 -1
index c50c1645c0ae..ded1af2ddae9 100644
@@ -126,7 +126,7 @@ int kvm_s390_pci_aen_init(u8 nisc)
 		return -EPERM;
 
 	mutex_lock(&aift->aift_lock);
-	aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev),
+	aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev *),
 			      GFP_KERNEL);
 	if (!aift->kzdev) {
 		rc = -ENOMEM;
maintainer
#2 lore raw
Quoted 7 lines · Matthew Rosato
Quoted 6 lines · Rafael Mendonca

The 'kzdev' field of struct 'zpci_aift' is an array of pointers to 'kvm_zdev' structs. Allocate the proper size accordingly.

Reported by Coccinelle:
WARNING: Use correct pointer type argument for sizeof

Quoted 6 lines
Quoted 2 lines
Fixes 98b1d33dac5f ("KVM: s390: pci: do initial setup for AEN interpretation")

Thanks for reporting & fixing.

After consulting Matt I've put this into the CI and I'll pick it once it received a bit of coverage.

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Rafael Mendonca

Am 26.10.22 um 03:32 schrieb Rafael Mendonca:

Quoted 8 lines

The 'kzdev' field of struct 'zpci_aift' is an array of pointers to 'kvm_zdev' structs. Allocate the proper size accordingly.

Reported by Coccinelle:
WARNING: Use correct pointer type argument for sizeof

Fixes 98b1d33dac5f ("KVM: s390: pci: do initial setup for AEN interpretation")
Quoted 17 lines
---
  arch/s390/kvm/pci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/pci.c +1 -1
index c50c1645c0ae..ded1af2ddae9 100644
@@ -126,7 +126,7 @@ int kvm_s390_pci_aen_init(u8 nisc)
  		return -EPERM;
 
  	mutex_lock(&aift->aift_lock);
-	aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev),
+	aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev *),
  			      GFP_KERNEL);
  	if (!aift->kzdev) {
  		rc = -ENOMEM;