]> git.karo-electronics.de Git - karo-tx-linux.git/commit
w1: fix netlink refcnt leak on error path
authorDavid Fries <David@Fries.net>
Wed, 9 Apr 2014 03:37:07 +0000 (22:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Apr 2014 21:07:51 +0000 (14:07 -0700)
commit593ceb0c7046c640cf463022189428a45219f595
treebda2945990912476effbe15289da3d4072c568d0
parenta82cb8b91a37b6015f171a90dc4670e4c8e12e12
w1: fix netlink refcnt leak on error path

If the message type is W1_MASTER_CMD or W1_SLAVE_CMD, then a reference
is taken when searching for the slave or master device.  If there
isn't any following data m->len (mlen is a copy) is 0 and packing up
the message for later execution is skipped leaving nothing to
decrement the reference counts.

Way back when, m->len was checked before the search that increments the
reference count, but W1_LIST_MASTERS has no additional data, the check
was moved in 9be62e0b2fadaf5ff causing this bug.

This change reorders to put the check before the reference count is
incremented avoiding the problem.

Signed-off-by: David Fries <David@Fries.net>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/w1_netlink.c