rtnetlink: potential ERR_PTR dereference
authorDan Carpenter <error27@gmail.com>
Wed, 21 Apr 2010 23:53:27 +0000 (23:53 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Apr 2010 22:57:26 +0000 (15:57 -0700)
In the original code, if rtnl_create_link() returned an ERR_PTR then that
would get passed to rtnl_configure_link() which dereferences it.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index 4568120d8533f557c3211f627aac69b41ce3abc5..fe776c9ddecab809e68fabe202d24911950803df 100644 (file)
@@ -1270,10 +1270,11 @@ replay:
                        err = ops->newlink(net, dev, tb, data);
                else
                        err = register_netdevice(dev);
-               if (err < 0 && !IS_ERR(dev)) {
+
+               if (err < 0 && !IS_ERR(dev))
                        free_netdev(dev);
+               if (err < 0)
                        goto out;
-               }
 
                err = rtnl_configure_link(dev, ifm);
                if (err < 0)