[libvirt] [PATCH] Fix potential false-positive OOM error reporting

Daniel Veillard veillard at redhat.com
Thu Oct 22 08:43:41 UTC 2009


On Wed, Oct 21, 2009 at 10:41:53PM +0200, Matthias Bolte wrote:
> If no matching device was found (cap == NULL) then no strdup() call
> was made and *wwnn and *wwpn are untouched. Checking them for NULL
> in this situation may result in reporting an false-positive OOM error
> because *wwnn and *wwpn may be initialized to NULL by the caller.
> 
> Only check *wwnn and *wwpn for NULL if a matching device was found
> (cap != NULL) and thus strdup() was called.
> 
> * src/conf/node_device_conf.c: only report an OOM error if there
>   really is one
> ---
>  src/conf/node_device_conf.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
> index 77f7be3..c2c5a44 100644
> --- a/src/conf/node_device_conf.c
> +++ b/src/conf/node_device_conf.c
> @@ -1243,9 +1243,7 @@ virNodeDeviceGetWWNs(virConnectPtr conn,
>          virNodeDeviceReportError(conn, VIR_ERR_NO_SUPPORT,
>                                   "%s", _("Device is not a fibre channel HBA"));
>          ret = -1;
> -    }
> -
> -    if (*wwnn == NULL || *wwpn == NULL) {
> +    } else if (*wwnn == NULL || *wwpn == NULL) {
>          /* Free the other one, if allocated... */
>          VIR_FREE(wwnn);
>          VIR_FREE(wwpn);

  Ah, right ! I remember going though this to avoid a segfault or leak
but I didn't expected that situation, ACK !

  thanks !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list