]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: fix crash when starting macvtap interfaces
authorLaine Stump <laine@laine.org>
Wed, 25 Apr 2012 19:49:44 +0000 (15:49 -0400)
committerLaine Stump <laine@laine.org>
Thu, 26 Apr 2012 00:55:26 +0000 (20:55 -0400)
commitf78024b9f594605053184ee41a5cba88ce3a2c8b
treef5ab019633025cf6be53448e3b853cd1799de033
parentbae13129c1283bd9e3d21a76f2d376a0f38b371d
util: fix crash when starting macvtap interfaces

This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270

The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
arg "virtPortProfile", and was checking it for non-NULL before using
it. However, the prototype for
virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
ATTRIBUTE_NONNULL(). Contrary to what one may think,
ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
as such really is always non-null; the only effect to the code
generated by gcc, is that gcc *assumes* it is non-NULL; this results
in, for example, the check for a non-NULL value being optimized out.

(Unfortunately, this code removal only occurs when optimization is
enabled, and I am in the habit of doing local builds with optimization
off to ease debugging, so the bug didn't show up in my earlier local
testing).

In general, virPortProfile might always be NULL, so it shouldn't be
marked as ATTRIBUTE_NONNULL. One other function prototype made this
same error, so this patch fixes it as well.
src/util/virnetdevmacvlan.h