linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements
@ 2022-10-26  1:32 Rafael Mendonca
  2022-10-26 13:36 ` Matthew Rosato
  2022-10-26 13:40 ` Christian Borntraeger
  0 siblings, 2 replies; 4+ messages in thread
From: Rafael Mendonca @ 2022-10-26  1:32 UTC (permalink / raw)
  To: Matthew Rosato, Eric Farman, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle
  Cc: Rafael Mendonca, linux-s390, kvm, linux-kernel

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")
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
---
 arch/s390/kvm/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index c50c1645c0ae..ded1af2ddae9 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements
  2022-10-26  1:32 [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements Rafael Mendonca
@ 2022-10-26 13:36 ` Matthew Rosato
  2022-10-26 14:54   ` Janosch Frank
  2022-10-26 13:40 ` Christian Borntraeger
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Rosato @ 2022-10-26 13:36 UTC (permalink / raw)
  To: Rafael Mendonca, Eric Farman, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle
  Cc: linux-s390, kvm, linux-kernel

On 10/25/22 9:32 PM, Rafael Mendonca wrote:
> 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")
> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>

Thanks for reporting & fixing.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>

> ---
>  arch/s390/kvm/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
> index c50c1645c0ae..ded1af2ddae9 100644
> --- a/arch/s390/kvm/pci.c
> +++ b/arch/s390/kvm/pci.c
> @@ -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;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements
  2022-10-26  1:32 [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements Rafael Mendonca
  2022-10-26 13:36 ` Matthew Rosato
@ 2022-10-26 13:40 ` Christian Borntraeger
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2022-10-26 13:40 UTC (permalink / raw)
  To: Rafael Mendonca, Matthew Rosato, Eric Farman, Janosch Frank,
	Claudio Imbrenda, David Hildenbrand, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Sven Schnelle
  Cc: linux-s390, kvm, linux-kernel

Am 26.10.22 um 03:32 schrieb 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")
> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>

> ---
>   arch/s390/kvm/pci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
> index c50c1645c0ae..ded1af2ddae9 100644
> --- a/arch/s390/kvm/pci.c
> +++ b/arch/s390/kvm/pci.c
> @@ -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;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements
  2022-10-26 13:36 ` Matthew Rosato
@ 2022-10-26 14:54   ` Janosch Frank
  0 siblings, 0 replies; 4+ messages in thread
From: Janosch Frank @ 2022-10-26 14:54 UTC (permalink / raw)
  To: Matthew Rosato, Rafael Mendonca, Eric Farman,
	Christian Borntraeger, Claudio Imbrenda, David Hildenbrand,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle
  Cc: linux-s390, kvm, linux-kernel

On 10/26/22 15:36, Matthew Rosato wrote:
> On 10/25/22 9:32 PM, Rafael Mendonca wrote:
>> 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")
>> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
> 
> Thanks for reporting & fixing.
> 
> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-26 14:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  1:32 [PATCH] KVM: s390: pci: Fix allocation size of aift kzdev elements Rafael Mendonca
2022-10-26 13:36 ` Matthew Rosato
2022-10-26 14:54   ` Janosch Frank
2022-10-26 13:40 ` Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).