On Tue, Feb 25, 2025 at 21:27:43 +0100, Roman Bogorodskiy wrote: > Peter Krempa wrote: [...] > > > Need to check if hostdev is NULL. > > > > That can't happen: > > > > virDomainHostdevDef * > > virDomainHostdevDefNew(void) > > { > > virDomainHostdevDef *def; > > > > def = g_new0(virDomainHostdevDef, 1); > > > > def->info = g_new0(virDomainDeviceInfo, 1); > > > > return def; > > } > > > > g_new0() abort()'s on OOM, thus this is guaranteed to return a valid > > pointer. > > > > Hm, interesting, that's been using g_new0() for about 5 years now. > > Looks like there are a few places that need to be clean up then, e.g. > right in the same file (conf/domain_conf.c) in virDomainHostdevDefParseXML(), and some drivers as well. Yeah; the thing is that many places were not cleaned up since the code was refactored to use g_new0 instead of VIR_ALLOC and this seems to be one of them. If you want to clean up stuff go ahead but for now we accept the fact that there are leftovers. It's just that new code doesn't necessarily need to add more checks.