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

Re: [libvirt] [PATCH 1/4] qemu: Check if virQEMUCapsNewCopy(...) has failed



On Thu, Feb 09, 2017 at 03:13 PM +0100, Marc Hartmayer <mhartmay linux vnet ibm com> wrote:
> Check if virQEMUCapsNewCopy(...) has failed, thus a segmentation fault
> in virQEMUCapsFilterByMachineType(...) will be avoided.
>
> Signed-off-by: Marc Hartmayer <mhartmay linux vnet ibm com>
> Reviewed-by: Bjoern Walk <bwalk linux vnet ibm com>
> ---
>  src/qemu/qemu_capabilities.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 3247d25..399e314 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -4928,6 +4928,10 @@ virQEMUCapsCacheLookupCopy(virCapsPtr caps,
>
>      ret = virQEMUCapsNewCopy(qemuCaps);
>      virObjectUnref(qemuCaps);
> +
> +    if (!ret)
> +        return NULL;
> +
>      virQEMUCapsFilterByMachineType(ret, machineType);
>      return ret;
>  }
> --
> 2.5.5
>

Another solution would be to add a cleanup path - not sure which one is better.

--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



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