Commit d699ca1e authored by Evgeniy Polyakov's avatar Evgeniy Polyakov Committed by Greg Kroah-Hartman

[PATCH] w1: do not stop and oops if netlink socket was not allocated.

Do not panic if netlink socket was not created.
This will allow only first device to broadcast it's slave updates.
We need kernel connector here.
Signed-off-by: default avatarEvgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 4e809b45
...@@ -89,11 +89,8 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, ...@@ -89,11 +89,8 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
dev->seq = 1; dev->seq = 1;
dev->nls = netlink_kernel_create(NETLINK_NFLOG, NULL); dev->nls = netlink_kernel_create(NETLINK_NFLOG, NULL);
if (!dev->nls) { if (!dev->nls) {
printk(KERN_ERR "Failed to create new netlink socket(%u).\n", printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
NETLINK_NFLOG); NETLINK_NFLOG, dev->dev.bus_id);
memset(dev, 0, sizeof(struct w1_master));
kfree(dev);
dev = NULL;
} }
err = device_register(&dev->dev); err = device_register(&dev->dev);
...@@ -112,7 +109,7 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, ...@@ -112,7 +109,7 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
void w1_free_dev(struct w1_master *dev) void w1_free_dev(struct w1_master *dev)
{ {
device_unregister(&dev->dev); device_unregister(&dev->dev);
if (dev->nls->sk_socket) if (dev->nls && dev->nls->sk_socket)
sock_release(dev->nls->sk_socket); sock_release(dev->nls->sk_socket);
memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
kfree(dev); kfree(dev);
......
...@@ -34,6 +34,9 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg) ...@@ -34,6 +34,9 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
struct w1_netlink_msg *data; struct w1_netlink_msg *data;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
if (!dev->nls)
return;
size = NLMSG_SPACE(sizeof(struct w1_netlink_msg)); size = NLMSG_SPACE(sizeof(struct w1_netlink_msg));
skb = alloc_skb(size, GFP_ATOMIC); skb = alloc_skb(size, GFP_ATOMIC);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment