On 04/09/2015 07:32 AM, Thomas Huth wrote:
> Current QEMU crashes when specifying an illegal model with the
> "-net nic,model=xxx" option, e.g.:
> 
>  $ qemu-system-x86_64 -net nic,model=n/a
>  qemu-system-x86_64: Unsupported NIC model: n/a
> 

> The problem is that pci_nic_init_nofail() does not check whether the err
> parameter from pci_nic_init has been set up and thus passes a NULL pointer
> to error_report_err(). Fix it by correctly checking the err parameter.
> 
> Signed-off-by: Thomas Huth <th...@redhat.com>
> ---
>  hw/pci/pci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 6941a82..b3d5100 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1660,7 +1660,9 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus 
> *rootbus,
>  
>      res = pci_nic_init(nd, rootbus, default_model, default_devaddr, &err);
>      if (!res) {
> -        error_report_err(err);
> +        if (err) {
> +            error_report_err(err);
> +        }
>          exit(1);

Doesn't this mean the program can exit without an error message, if
pci_nic_init returns failure but failed to set err?  Shouldn't you at
least print something in that case as an else branch?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to