Re: [Qemu-devel] [PATCH] pci-pc: add NULL check for qpci_free_pc

2018-07-27 Thread Stefan Hajnoczi
On Mon, Jul 23, 2018 at 12:43:42PM +0200, Emanuele Giuseppe Esposito wrote: > The current layout of struct QPCIBusPC provides only one field, > QPCIBus bus, so passing a NULL pointer to qpci_free_pc() > makes container_of(NULL, QPCIBusPC, bus) > returning 0 (NULL), that is correctly handled by

[Qemu-devel] [PATCH] pci-pc: add NULL check for qpci_free_pc

2018-07-23 Thread Emanuele Giuseppe Esposito
The current layout of struct QPCIBusPC provides only one field, QPCIBus bus, so passing a NULL pointer to qpci_free_pc() makes container_of(NULL, QPCIBusPC, bus) returning 0 (NULL), that is correctly handled by g_free(). This is bad practice, allowing the caller to think that it's okay to always