[lldp-devel] [PATCH] lldpad: Avoid possible resource leak in get_bcn()

John Fastabend john.r.fastabend at intel.com
Tue Aug 16 01:12:07 UTC 2011


On 8/8/2011 6:21 AM, Petr Sabata wrote:
> Signed-off-by: Petr Sabata <contyk at redhat.com>
> ---
>  nltest.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/nltest.c b/nltest.c
> index 2ae2212..e350ca9 100644
> --- a/nltest.c
> +++ b/nltest.c
> @@ -781,12 +781,14 @@ static int get_bcn(char *ifname, bcn_cfg *bcn_data)
>  
>  	if (d->cmd != DCB_CMD_BCN_GCFG) {
>  		printf("Hmm, this is not the message we were expecting.\n");
> +		free(nlh);
>  		return -EIO;
>  	}
>  	if (rta_parent->rta_type != DCB_ATTR_BCN) {
>  		/* Do we really want to code up an attribute parser?? */
>  		printf("A full libnetlink (with rtnl and attribute support) "
>  		       "would sure be nice.\n");
> +		free(nlh);
>  		return -EIO;
>  	}
>  	rta_child = NLA_DATA(rta_parent);


Applied thanks Petr. But we may be missing the same free() in this routine
slightly above these fixes. Also at some point I would like to rework nltest
and make it more useful for scripted testing.

Thanks,
John.



More information about the lldp-devel mailing list