On Thu, Jul 13, 2017 at 01:02:31PM +0200, Ladi Prosek wrote: > +static const char *virtio_get_device_id(VirtIODevice *vdev) > +{ > + DeviceState *qdev = DEVICE(vdev); > + while (qdev) { > + /* Find the proxy object corresponding to the vdev backend */ > + Object *prop = object_property_get_link(OBJECT(qdev), > + VIRTIO_PROP_BACKEND, NULL); > + if (prop == OBJECT(vdev)) { > + return qdev->id; > + } > + qdev = qdev->parent_bus->parent; > + } > + return NULL; > +} > + > void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, > ...) > { > va_list ap; > > + error_report_nolf("%s (id=%s): ", vdev->name, > virtio_get_device_id(vdev));
virtio_get_device_id() can return NULL. POSIX does not guarantee that the printf(3) family functions handle "%s", NULL safely. glibc prints "(null)" but other libc implementations crash (e.g. Solaris). http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html Should the return NULL above have g_assert_not_reached()? That would communicate the assumption that we never reach return NULL and it might silence static checkers like Coverity but I'm not sure.
signature.asc
Description: PGP signature