All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory
@ 2017-03-27  3:23 Alexey Kardashevskiy
  2017-03-27  4:24 ` David Gibson
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Kardashevskiy @ 2017-03-27  3:23 UTC (permalink / raw)
  To: kvm; +Cc: Alexey Kardashevskiy, David Gibson, Alex Williamson

This adds missing checking for kzalloc() return value.

Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index cf3de91fbfe7..c298bb36e27a 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -198,6 +198,11 @@ static long tce_iommu_register_pages(struct tce_container *container,
 		return ret;
 
 	tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
+	if (!tcemem) {
+		mm_iommu_put(container->mm, mem);
+		return -ENOMEM;
+	}
+
 	tcemem->mem = mem;
 	list_add(&tcemem->next, &container->prereg_list);
 
-- 
2.11.0

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

* Re: [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory
  2017-03-27  3:23 [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory Alexey Kardashevskiy
@ 2017-03-27  4:24 ` David Gibson
  2017-04-11  8:27   ` Alexey Kardashevskiy
  0 siblings, 1 reply; 5+ messages in thread
From: David Gibson @ 2017-03-27  4:24 UTC (permalink / raw)
  To: Alexey Kardashevskiy; +Cc: kvm, Alex Williamson

[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]

On Mon, Mar 27, 2017 at 02:23:40PM +1100, Alexey Kardashevskiy wrote:
> This adds missing checking for kzalloc() return value.
> 
> Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index cf3de91fbfe7..c298bb36e27a 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -198,6 +198,11 @@ static long tce_iommu_register_pages(struct tce_container *container,
>  		return ret;
>  
>  	tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
> +	if (!tcemem) {
> +		mm_iommu_put(container->mm, mem);
> +		return -ENOMEM;
> +	}
> +
>  	tcemem->mem = mem;
>  	list_add(&tcemem->next, &container->prereg_list);
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory
  2017-03-27  4:24 ` David Gibson
@ 2017-04-11  8:27   ` Alexey Kardashevskiy
  2017-04-11 19:53     ` Alex Williamson
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Kardashevskiy @ 2017-04-11  8:27 UTC (permalink / raw)
  To: Alex Williamson; +Cc: David Gibson, kvm


[-- Attachment #1.1: Type: text/plain, Size: 1118 bytes --]

On 27/03/17 15:24, David Gibson wrote:
> On Mon, Mar 27, 2017 at 02:23:40PM +1100, Alexey Kardashevskiy wrote:
>> This adds missing checking for kzalloc() return value.
>>
>> Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown")
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>


Alex?


> 
>> ---
>>  drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
>> index cf3de91fbfe7..c298bb36e27a 100644
>> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
>> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
>> @@ -198,6 +198,11 @@ static long tce_iommu_register_pages(struct tce_container *container,
>>  		return ret;
>>  
>>  	tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
>> +	if (!tcemem) {
>> +		mm_iommu_put(container->mm, mem);
>> +		return -ENOMEM;
>> +	}
>> +
>>  	tcemem->mem = mem;
>>  	list_add(&tcemem->next, &container->prereg_list);
>>  
> 


-- 
Alexey


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 839 bytes --]

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

* Re: [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory
  2017-04-11  8:27   ` Alexey Kardashevskiy
@ 2017-04-11 19:53     ` Alex Williamson
  2017-04-11 23:40       ` Alexey Kardashevskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2017-04-11 19:53 UTC (permalink / raw)
  To: Alexey Kardashevskiy; +Cc: David Gibson, kvm

On Tue, 11 Apr 2017 18:27:49 +1000
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:

> On 27/03/17 15:24, David Gibson wrote:
> > On Mon, Mar 27, 2017 at 02:23:40PM +1100, Alexey Kardashevskiy wrote:  
> >> This adds missing checking for kzalloc() return value.
> >>
> >> Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown")
> >> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>  
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>  
> 
> 
> Alex?

I've updated my next branch, I've got these from you:

3393af24b665 vfio/spapr_tce: Check kzalloc() return when preregistering memory
1282ba7fc28d vfio/powerpc/spapr_tce: Enforce IOMMU type compatibility check

Am I missing anything else that needs to go through my tree for v4.12?
Thanks,

Alex
  
> >> ---
> >>  drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
> >>  1 file changed, 5 insertions(+)
> >>
> >> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c
> >> b/drivers/vfio/vfio_iommu_spapr_tce.c index
> >> cf3de91fbfe7..c298bb36e27a 100644 ---
> >> a/drivers/vfio/vfio_iommu_spapr_tce.c +++
> >> b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -198,6 +198,11 @@ static
> >> long tce_iommu_register_pages(struct tce_container *container,
> >> return ret; 
> >>  	tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
> >> +	if (!tcemem) {
> >> +		mm_iommu_put(container->mm, mem);
> >> +		return -ENOMEM;
> >> +	}
> >> +
> >>  	tcemem->mem = mem;
> >>  	list_add(&tcemem->next, &container->prereg_list);
> >>    
> >   
> 
> 

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

* Re: [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory
  2017-04-11 19:53     ` Alex Williamson
@ 2017-04-11 23:40       ` Alexey Kardashevskiy
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2017-04-11 23:40 UTC (permalink / raw)
  To: Alex Williamson; +Cc: David Gibson, kvm

On 12/04/17 05:53, Alex Williamson wrote:
> On Tue, 11 Apr 2017 18:27:49 +1000
> Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> 
>> On 27/03/17 15:24, David Gibson wrote:
>>> On Mon, Mar 27, 2017 at 02:23:40PM +1100, Alexey Kardashevskiy wrote:  
>>>> This adds missing checking for kzalloc() return value.
>>>>
>>>> Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown")
>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>  
>>>
>>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>  
>>
>>
>> Alex?
> 
> I've updated my next branch, I've got these from you:
> 
> 3393af24b665 vfio/spapr_tce: Check kzalloc() return when preregistering memory
> 1282ba7fc28d vfio/powerpc/spapr_tce: Enforce IOMMU type compatibility check
> 
> Am I missing anything else that needs to go through my tree for v4.12?

No, this is all I wanted, thanks. I just did not see in any of your trees
but I see it now.


> Thanks,
> 
> Alex
>   
>>>> ---
>>>>  drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
>>>>  1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c
>>>> b/drivers/vfio/vfio_iommu_spapr_tce.c index
>>>> cf3de91fbfe7..c298bb36e27a 100644 ---
>>>> a/drivers/vfio/vfio_iommu_spapr_tce.c +++
>>>> b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -198,6 +198,11 @@ static
>>>> long tce_iommu_register_pages(struct tce_container *container,
>>>> return ret; 
>>>>  	tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
>>>> +	if (!tcemem) {
>>>> +		mm_iommu_put(container->mm, mem);
>>>> +		return -ENOMEM;
>>>> +	}
>>>> +
>>>>  	tcemem->mem = mem;
>>>>  	list_add(&tcemem->next, &container->prereg_list);
>>>>    
>>>   
>>
>>
> 


-- 
Alexey

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

end of thread, other threads:[~2017-04-11 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27  3:23 [PATCH kernel] vfio/spapr_tce: Check kzalloc() return when preregistering memory Alexey Kardashevskiy
2017-03-27  4:24 ` David Gibson
2017-04-11  8:27   ` Alexey Kardashevskiy
2017-04-11 19:53     ` Alex Williamson
2017-04-11 23:40       ` Alexey Kardashevskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.