Message ID | 1499101594-22421-1-git-send-email-eduval@amazon.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Eduardo Valentin <eduval@amazon.com> Date: Mon, 3 Jul 2017 10:06:34 -0700 > We currently get the following kmemleak report: ... > This patch flags the complete_info ptr object as not a leak as it will > get freed when .complete_priv() is called, We don't call .complete_priv(). We call .complete(). for the br mdb case, it > will be freed at br_mdb_complete(). > > Cc: stable <stable@vger.kernel.org> # v4.9+ > Reviewed-by: Vallish Vaidyeshwara <vallish@amazon.com> > Signed-off-by: Eduardo Valentin <eduval@amazon.com> I don't understand why kmemleak cannot see this. We store the pointer globally when we do the switchdev_port_obv_add() call and it should be able to see that.
On Tue, Jul 04, 2017 at 01:48:42AM -0700, David Miller wrote: > From: Eduardo Valentin <eduval@amazon.com> > Date: Mon, 3 Jul 2017 10:06:34 -0700 > > > We currently get the following kmemleak report: > ... > > This patch flags the complete_info ptr object as not a leak as it will > > get freed when .complete_priv() is called, > > We don't call .complete_priv(). We call .complete(). True, I can fix this wording in the commit next version. > > for the br mdb case, it > > will be freed at br_mdb_complete(). > > > > Cc: stable <stable@vger.kernel.org> # v4.9+ > > Reviewed-by: Vallish Vaidyeshwara <vallish@amazon.com> > > Signed-off-by: Eduardo Valentin <eduval@amazon.com> > > I don't understand why kmemleak cannot see this. > > We store the pointer globally when we do the switchdev_port_obv_add() > call and it should be able to see that. I see and agree. But even then I get these reports consistently on RTM_NEWMDB type. This is why I am proposing marking as a non-kmemleak. To me, this is only a leak if .complete() never gets called.
On Wed, Jul 05, 2017 at 09:05:14AM -0700, Eduardo Valentin wrote: > On Tue, Jul 04, 2017 at 01:48:42AM -0700, David Miller wrote: > > From: Eduardo Valentin <eduval@amazon.com> > > Date: Mon, 3 Jul 2017 10:06:34 -0700 > > > > > We currently get the following kmemleak report: > > ... > > > This patch flags the complete_info ptr object as not a leak as it will > > > get freed when .complete_priv() is called, > > > > We don't call .complete_priv(). We call .complete(). > > True, I can fix this wording in the commit next version. > > > > > for the br mdb case, it > > > will be freed at br_mdb_complete(). > > > > > > Cc: stable <stable@vger.kernel.org> # v4.9+ > > > Reviewed-by: Vallish Vaidyeshwara <vallish@amazon.com> > > > Signed-off-by: Eduardo Valentin <eduval@amazon.com> > > > > I don't understand why kmemleak cannot see this. > > > > We store the pointer globally when we do the switchdev_port_obv_add() > > call and it should be able to see that. > > I see and agree. But even then I get these reports consistently on RTM_NEWMDB type. > This is why I am proposing marking as a non-kmemleak. > > To me, this is only a leak if .complete() never gets called. Ok. So, in fact, I believe the problem I am seeing in more when switchdev_port_obj_add() fails. I will send a patch for that. > > > -- > All the best, > Eduardo Valentin
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index b084548..1c81546 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -5,6 +5,7 @@ #include <linux/rculist.h> #include <linux/skbuff.h> #include <linux/if_ether.h> +#include <linux/kmemleak.h> #include <net/ip.h> #include <net/netlink.h> #include <net/switchdev.h> @@ -319,6 +320,8 @@ static void __br_mdb_notify(struct net_device *dev, struct net_bridge_port *p, if (port_dev && type == RTM_NEWMDB) { complete_info = kmalloc(sizeof(*complete_info), GFP_ATOMIC); if (complete_info) { + /* This pointer is freed in br_mdb_complete() */ + kmemleak_not_leak(complete_info); complete_info->port = p; __mdb_entry_to_br_ip(entry, &complete_info->ip); mdb.obj.complete_priv = complete_info;