mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
vfio-pci/zdev: fix possible segmentation fault issue
[ Upstream commit7e31d6dc2c] In case allocation fails, we must behave correctly and exit with error. Fixes:e6b817d4b8("vfio-pci/zdev: Add zPCI capabilities to VFIO_DEVICE_GET_INFO") Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c0e73c1d6d
commit
9eb145398e
@@ -74,6 +74,8 @@ static int zpci_util_cap(struct zpci_dev *zdev, struct vfio_pci_device *vdev,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cap = kmalloc(cap_size, GFP_KERNEL);
|
cap = kmalloc(cap_size, GFP_KERNEL);
|
||||||
|
if (!cap)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
cap->header.id = VFIO_DEVICE_INFO_CAP_ZPCI_UTIL;
|
cap->header.id = VFIO_DEVICE_INFO_CAP_ZPCI_UTIL;
|
||||||
cap->header.version = 1;
|
cap->header.version = 1;
|
||||||
@@ -98,6 +100,8 @@ static int zpci_pfip_cap(struct zpci_dev *zdev, struct vfio_pci_device *vdev,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cap = kmalloc(cap_size, GFP_KERNEL);
|
cap = kmalloc(cap_size, GFP_KERNEL);
|
||||||
|
if (!cap)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
cap->header.id = VFIO_DEVICE_INFO_CAP_ZPCI_PFIP;
|
cap->header.id = VFIO_DEVICE_INFO_CAP_ZPCI_PFIP;
|
||||||
cap->header.version = 1;
|
cap->header.version = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user