Re: [PATCH 6/9] vfio-pci/zdev: fix possible segmentation fault issue

2021-02-02 Thread Cornelia Huck
On Mon, 1 Feb 2021 13:47:57 -0700
Alex Williamson  wrote:

> On Mon, 1 Feb 2021 12:08:45 -0500
> Matthew Rosato  wrote:
> 
> > On 2/1/21 11:52 AM, Cornelia Huck wrote:  
> > > On Mon, 1 Feb 2021 16:28:25 +
> > > Max Gurtovoy  wrote:
> > > 
> > >> In case allocation fails, we must behave correctly and exit with error.
> > >>
> > >> Signed-off-by: Max Gurtovoy 
> > > 
> > > Fixes: e6b817d4b821 ("vfio-pci/zdev: Add zPCI capabilities to 
> > > VFIO_DEVICE_GET_INFO")
> > > 
> > > Reviewed-by: Cornelia Huck 
> > > 
> > > I think this should go in independently of this series. >
> > 
> > Agreed, makes sense to me -- thanks for finding.
> > 
> > Reviewed-by: Matthew Rosato   
> 
> I can grab this one, and 5/9.  Connie do you want to toss an R-b at
> 5/9?  Thanks,
> 
> Alex

Yes, makes sense to grab these two. R-b added.



Re: [PATCH 6/9] vfio-pci/zdev: fix possible segmentation fault issue

2021-02-01 Thread Alex Williamson
On Mon, 1 Feb 2021 12:08:45 -0500
Matthew Rosato  wrote:

> On 2/1/21 11:52 AM, Cornelia Huck wrote:
> > On Mon, 1 Feb 2021 16:28:25 +
> > Max Gurtovoy  wrote:
> >   
> >> In case allocation fails, we must behave correctly and exit with error.
> >>
> >> Signed-off-by: Max Gurtovoy   
> > 
> > Fixes: e6b817d4b821 ("vfio-pci/zdev: Add zPCI capabilities to 
> > VFIO_DEVICE_GET_INFO")
> > 
> > Reviewed-by: Cornelia Huck 
> > 
> > I think this should go in independently of this series. >  
> 
> Agreed, makes sense to me -- thanks for finding.
> 
> Reviewed-by: Matthew Rosato 

I can grab this one, and 5/9.  Connie do you want to toss an R-b at
5/9?  Thanks,

Alex



Re: [PATCH 6/9] vfio-pci/zdev: fix possible segmentation fault issue

2021-02-01 Thread Matthew Rosato

On 2/1/21 11:52 AM, Cornelia Huck wrote:

On Mon, 1 Feb 2021 16:28:25 +
Max Gurtovoy  wrote:


In case allocation fails, we must behave correctly and exit with error.

Signed-off-by: Max Gurtovoy 


Fixes: e6b817d4b821 ("vfio-pci/zdev: Add zPCI capabilities to 
VFIO_DEVICE_GET_INFO")

Reviewed-by: Cornelia Huck 

I think this should go in independently of this series. >


Agreed, makes sense to me -- thanks for finding.

Reviewed-by: Matthew Rosato 


---
  drivers/vfio/pci/vfio_pci_zdev.c | 4 
  1 file changed, 4 insertions(+)






Re: [PATCH 6/9] vfio-pci/zdev: fix possible segmentation fault issue

2021-02-01 Thread Cornelia Huck
On Mon, 1 Feb 2021 16:28:25 +
Max Gurtovoy  wrote:

> In case allocation fails, we must behave correctly and exit with error.
> 
> Signed-off-by: Max Gurtovoy 

Fixes: e6b817d4b821 ("vfio-pci/zdev: Add zPCI capabilities to 
VFIO_DEVICE_GET_INFO")

Reviewed-by: Cornelia Huck 

I think this should go in independently of this series.

> ---
>  drivers/vfio/pci/vfio_pci_zdev.c | 4 
>  1 file changed, 4 insertions(+)



[PATCH 6/9] vfio-pci/zdev: fix possible segmentation fault issue

2021-02-01 Thread Max Gurtovoy
In case allocation fails, we must behave correctly and exit with error.

Signed-off-by: Max Gurtovoy 
---
 drivers/vfio/pci/vfio_pci_zdev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c
index 175096fcd902..e9ef4239ef7a 100644
--- a/drivers/vfio/pci/vfio_pci_zdev.c
+++ b/drivers/vfio/pci/vfio_pci_zdev.c
@@ -71,6 +71,8 @@ static int zpci_util_cap(struct zpci_dev *zdev, struct 
vfio_info_cap *caps)
int ret;
 
cap = kmalloc(cap_size, GFP_KERNEL);
+   if (!cap)
+   return -ENOMEM;
 
cap->header.id = VFIO_DEVICE_INFO_CAP_ZPCI_UTIL;
cap->header.version = 1;
@@ -94,6 +96,8 @@ static int zpci_pfip_cap(struct zpci_dev *zdev, struct 
vfio_info_cap *caps)
int ret;
 
cap = kmalloc(cap_size, GFP_KERNEL);
+   if (!cap)
+   return -ENOMEM;
 
cap->header.id = VFIO_DEVICE_INFO_CAP_ZPCI_PFIP;
cap->header.version = 1;
-- 
2.25.4