[PATCH] Bug Fix: cache_include: Fix object ref release after successful object update

Thomas Graf tgraf at suug.ch
Mon Dec 17 09:18:43 EST 2012


On 12/12/12 at 09:48pm, roopa at cumulusnetworks.com wrote:
> From: roopa <roopa at cumulusnetworks.com>
> 
> The current code does a rtnl_link_put on new object instead of
> old object. This patch fixes it. None of the caches have support
> for object update, so this should not have affected anyone yet.
> 
> Signed-off-by: Roopa Prabhu <roopa at cumulusnetworks.com>
> ---
>  lib/cache.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/cache.c b/lib/cache.c
> index 283f1ac..04da99a 100644
> --- a/lib/cache.c
> +++ b/lib/cache.c
> @@ -750,7 +750,7 @@ static int cache_include(struct nl_cache *cache, struct nl_object *obj,
>  			 */
>  			if (nl_object_update(old, obj) == 0) {
>  				cb(cache, old, NL_ACT_CHANGE, data);
> -				nl_object_put(obj);
> +				nl_object_put(old);
>  				return 0;
>  			}

The nl_object_put(obj) is obviously wrong but do we really need to
decrement the reference counter of the old object? It was updated
but needs to stay, right?

I think we don't need to touch any ref counters at all. The ref
counter of 'obj' will be dec'ed in the parser function of the
respective object type and the ref counter of 'old' should be
unchanged as it was only updated.

Do you agree?



More information about the libnl mailing list