Re: [libvirt PATCH 3/3] nodedev: handle null return from GetIOMMUGroupDev()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 13, 2021 at 03:49:33PM -0500, Jonathon Jongsma wrote:
> Coverity reported that this function can return NULL, so it should be
> handled properly.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
> ---
>  src/node_device/node_device_driver.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> index 5f8995172d..2fcebd065b 100644
> --- a/src/node_device/node_device_driver.c
> +++ b/src/node_device/node_device_driver.c
> @@ -1192,9 +1192,18 @@ nodeDeviceDestroy(virNodeDevicePtr device)
>           * shouldn't try to remove the device. */
>          g_autofree char *vfiogroup =
>              virMediatedDeviceGetIOMMUGroupDev(def->caps->data.mdev.uuid);
> -        VIR_AUTOCLOSE fd = open(vfiogroup, O_RDONLY);
> +        VIR_AUTOCLOSE fd = -1;
>          g_autofree char *errmsg = NULL;
>  
> +        if (!vfiogroup) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           _("Unable to determine iommu group for '%s'"),
> +                           def->name);

This will lead to error stacking - virMediatedDeviceGetIOMMUGroupDev already
reported an error for you at this point.

Erik




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux