bridge: fix error handling in br_add_if()
authorVolodymyr G Lukiianyk <volodymyrgl@gmail.com>
Tue, 29 Apr 2008 10:17:42 +0000 (03:17 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 Apr 2008 10:17:42 +0000 (03:17 -0700)
When device is added to bridge its refcnt is incremented (in new_nbp()), but if
error occurs during further br_add_if() operations this counter is not
decremented back. Fix it by adding dev_put() call in the error path.

Signed-off-by: Volodymyr G Lukiianyk <volodymyrgl@gmail.com>
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_if.c

index 298e0f463c56e0aa67d7e876fee6255255b12bc1..77a981a1ee52249d5fbed7966f294afe7730ffb3 100644 (file)
@@ -411,9 +411,12 @@ err2:
        br_fdb_delete_by_port(br, p, 1);
 err1:
        kobject_del(&p->kobj);
-       return err;
+       goto put_back;
 err0:
        kobject_put(&p->kobj);
+
+put_back:
+       dev_put(dev);
        return err;
 }