From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Sutter Subject: Re: [PATCH iproute2] iplink_vrf: Save device index from response for return code Date: Fri, 1 Jun 2018 19:05:49 +0200 Message-ID: <20180601170549.GO16785@orbyte.nwl.cc> References: <20180601155016.3524-1-dsahern@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: stephen@networkplumber.org, netdev@vger.kernel.org, David Ahern , Hangbin Liu To: dsahern@kernel.org Return-path: Received: from orbyte.nwl.cc ([151.80.46.58]:46160 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbeFARFw (ORCPT ); Fri, 1 Jun 2018 13:05:52 -0400 Content-Disposition: inline In-Reply-To: <20180601155016.3524-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, Jun 01, 2018 at 08:50:16AM -0700, dsahern@kernel.org wrote: > From: David Ahern > > A recent commit changed rtnl_talk_* to return the response message in > allocated memory so callers need to free it. The change to name_is_vrf > did not save the device index which is pointing to a struct inside the > now allocated and freed memory resulting in garbage getting returned > in some cases. > > Fix by using a stack variable to save the return value and only set > it to ifi->ifi_index after all checks are done and before the answer > buffer is freed. > > Fixes: 86bf43c7c2fdc ("lib/libnetlink: update rtnl_talk to support malloc buff at run time") > Cc: Hangbin Liu > Cc: Phil Sutter > Signed-off-by: David Ahern Acked-by: Phil Sutter Thanks, Phil