[Libvirt-cim] [PATCH 1 of 2] Fix an issue where EnabledLogicalElementCapabilities ein/ei returns an error

Dan Smith danms at us.ibm.com
Tue Nov 27 23:44:33 UTC 2007


KR> +        count = get_domain_list(conn, &list);
KR> +        if (count <= 0)
KR> +                goto out;

You create the list before the for() loop,

KR> +
KR> +        for (i = 0; i < count; i++) {
KR> +                name = virDomainGetName(list[i]);
KR> +                if (name == NULL) {
KR> +                        cu_statusf(_BROKER, &s,
KR> +                                   CMPI_RC_ERR_FAILED,
KR> +                                   "Unable to get domain names");
KR> +                        goto end;
KR> +                }
KR> +
KR> +                s = get_ele_cap(_BROKER, ref, name, &inst);
KR> +                if (s.rc != CMPI_RC_OK)
KR> +                        goto end;
KR> +
KR> +                if (names_only)
KR> +                        cu_return_instance_name(results, inst);
KR> +                else
KR> +                        CMReturnInstance(results, inst);
KR> +
KR> +          end:
KR> +                virDomainFree(list[i]);
KR> +
KR> +                if (s.rc != CMPI_RC_OK)
KR> +                        goto out;

But then clean it up every time through the loop, which should be
causing a crash on the 1..n iterations.  If you're not seeing a
crash, I imagine you're getting lucky.  virDomainFree() protects
against a double-free with some magic, I think, but using list after
the first time through here is broken.

-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms at us.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20071127/47dca3fd/attachment.sig>


More information about the Libvirt-cim mailing list