[PATCH] net: ieee802154: fix net_device reference release too early

2017-05-18 Thread linzhang
This patch fixes the kernel oops when release net_device reference in 
advance. In function raw_sendmsg(i think the dgram_sendmsg has the same 
problem), there is a race condition between dev_put and dev_queue_xmit
when the device is gong that maybe lead to dev_queue_ximt to see
an illegal net_device pointer.

So i think that dev_put should be behind of the dev_queue_xmit.

Also, explicit set skb->sk is needless, sock_alloc_send_skb is
already set it.

Signed-off-by: linzhang <xiaolou4...@gmail.com>
---
 net/ieee802154/socket.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
index eedba76..a60658c 100644
--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
@@ -301,15 +301,14 @@ static int raw_sendmsg(struct sock *sk, struct msghdr 
*msg, size_t size)
goto out_skb;
 
skb->dev = dev;
-   skb->sk  = sk;
skb->protocol = htons(ETH_P_IEEE802154);
 
-   dev_put(dev);
-
err = dev_queue_xmit(skb);
if (err > 0)
err = net_xmit_errno(err);
 
+   dev_put(dev);
+
return err ?: size;
 
 out_skb:
@@ -690,15 +689,14 @@ static int dgram_sendmsg(struct sock *sk, struct msghdr 
*msg, size_t size)
goto out_skb;
 
skb->dev = dev;
-   skb->sk  = sk;
skb->protocol = htons(ETH_P_IEEE802154);
 
-   dev_put(dev);
-
err = dev_queue_xmit(skb);
if (err > 0)
err = net_xmit_errno(err);
 
+   dev_put(dev);
+
return err ?: size;
 
 out_skb:
-- 
1.8.3.1



[PATCH] net: ieee802154: fix net_device reference release too early

2017-05-18 Thread linzhang
This patch fixes the kernel oops when release net_device reference in 
advance. In function raw_sendmsg(i think the dgram_sendmsg has the same 
problem), there is a race condition between dev_put and dev_queue_xmit
when the device is gong that maybe lead to dev_queue_ximt to see
an illegal net_device pointer.

So i think that dev_put should be behind of the dev_queue_xmit.

Also, explicit set skb->sk is needless, sock_alloc_send_skb is
already set it.

Signed-off-by: linzhang 
---
 net/ieee802154/socket.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
index eedba76..a60658c 100644
--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
@@ -301,15 +301,14 @@ static int raw_sendmsg(struct sock *sk, struct msghdr 
*msg, size_t size)
goto out_skb;
 
skb->dev = dev;
-   skb->sk  = sk;
skb->protocol = htons(ETH_P_IEEE802154);
 
-   dev_put(dev);
-
err = dev_queue_xmit(skb);
if (err > 0)
err = net_xmit_errno(err);
 
+   dev_put(dev);
+
return err ?: size;
 
 out_skb:
@@ -690,15 +689,14 @@ static int dgram_sendmsg(struct sock *sk, struct msghdr 
*msg, size_t size)
goto out_skb;
 
skb->dev = dev;
-   skb->sk  = sk;
skb->protocol = htons(ETH_P_IEEE802154);
 
-   dev_put(dev);
-
err = dev_queue_xmit(skb);
if (err > 0)
err = net_xmit_errno(err);
 
+   dev_put(dev);
+
return err ?: size;
 
 out_skb:
-- 
1.8.3.1



[PATCH net v3] net: x25: fix one potential use-after-free issue

2017-05-16 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add properly unregister call on error handler.

Also, i adjust the coding style and make x25_register_sysctl properly
return failure.

Signed-off-by: linzhang <xiaolou4...@gmail.com>
---

changelog:

v1 -> v2:
* make x25_register_sysctl properly return failure

v2 -> v3:
* keep the same lables as v1
* fix missing semicolon

---
 include/net/x25.h|  4 ++--
 net/x25/af_x25.c | 24 
 net/x25/sysctl_net_x25.c |  5 -
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/include/net/x25.h b/include/net/x25.h
index c383aa4..6d30a01 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -298,10 +298,10 @@ int x25_decode(struct sock *, struct sk_buff *, int *, 
int *, int *, int *,
 
 /* sysctl_net_x25.c */
 #ifdef CONFIG_SYSCTL
-void x25_register_sysctl(void);
+int x25_register_sysctl(void);
 void x25_unregister_sysctl(void);
 #else
-static inline void x25_register_sysctl(void) {};
+static inline int x25_register_sysctl(void) { return 0; };
 static inline void x25_unregister_sysctl(void) {};
 #endif /* CONFIG_SYSCTL */
 
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..5a1a98d 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1791,32 +1791,40 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
 
 static int __init x25_init(void)
 {
-   int rc = proto_register(_proto, 0);
+   int rc;
 
-   if (rc != 0)
+   rc = proto_register(_proto, 0);
+   if (rc)
goto out;
 
rc = sock_register(_family_ops);
-   if (rc != 0)
+   if (rc)
goto out_proto;
 
dev_add_pack(_packet_type);
 
rc = register_netdevice_notifier(_dev_notifier);
-   if (rc != 0)
+   if (rc)
goto out_sock;
 
-   pr_info("Linux Version 0.2\n");
+   rc = x25_register_sysctl();
+   if (rc)
+   goto out_dev;
 
-   x25_register_sysctl();
rc = x25_proc_init();
-   if (rc != 0)
-   goto out_dev;
+   if (rc)
+   goto out_sysctl;
+
+   pr_info("Linux Version 0.2\n");
+
 out:
return rc;
+out_sysctl:
+   x25_unregister_sysctl();
 out_dev:
unregister_netdevice_notifier(_dev_notifier);
 out_sock:
+   dev_remove_pack(_packet_type);
sock_unregister(AF_X25);
 out_proto:
proto_unregister(_proto);
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe1..ba078c8 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@
{ },
 };
 
-void __init x25_register_sysctl(void)
+int __init x25_register_sysctl(void)
 {
x25_table_header = register_net_sysctl(_net, "net/x25", x25_table);
+   if (!x25_table_header)
+   return -ENOMEM;
+   return 0;
 }
 
 void x25_unregister_sysctl(void)
-- 
1.8.3.1



[PATCH net v3] net: x25: fix one potential use-after-free issue

2017-05-16 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add properly unregister call on error handler.

Also, i adjust the coding style and make x25_register_sysctl properly
return failure.

Signed-off-by: linzhang 
---

changelog:

v1 -> v2:
* make x25_register_sysctl properly return failure

v2 -> v3:
* keep the same lables as v1
* fix missing semicolon

---
 include/net/x25.h|  4 ++--
 net/x25/af_x25.c | 24 
 net/x25/sysctl_net_x25.c |  5 -
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/include/net/x25.h b/include/net/x25.h
index c383aa4..6d30a01 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -298,10 +298,10 @@ int x25_decode(struct sock *, struct sk_buff *, int *, 
int *, int *, int *,
 
 /* sysctl_net_x25.c */
 #ifdef CONFIG_SYSCTL
-void x25_register_sysctl(void);
+int x25_register_sysctl(void);
 void x25_unregister_sysctl(void);
 #else
-static inline void x25_register_sysctl(void) {};
+static inline int x25_register_sysctl(void) { return 0; };
 static inline void x25_unregister_sysctl(void) {};
 #endif /* CONFIG_SYSCTL */
 
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..5a1a98d 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1791,32 +1791,40 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
 
 static int __init x25_init(void)
 {
-   int rc = proto_register(_proto, 0);
+   int rc;
 
-   if (rc != 0)
+   rc = proto_register(_proto, 0);
+   if (rc)
goto out;
 
rc = sock_register(_family_ops);
-   if (rc != 0)
+   if (rc)
goto out_proto;
 
dev_add_pack(_packet_type);
 
rc = register_netdevice_notifier(_dev_notifier);
-   if (rc != 0)
+   if (rc)
goto out_sock;
 
-   pr_info("Linux Version 0.2\n");
+   rc = x25_register_sysctl();
+   if (rc)
+   goto out_dev;
 
-   x25_register_sysctl();
rc = x25_proc_init();
-   if (rc != 0)
-   goto out_dev;
+   if (rc)
+   goto out_sysctl;
+
+   pr_info("Linux Version 0.2\n");
+
 out:
return rc;
+out_sysctl:
+   x25_unregister_sysctl();
 out_dev:
unregister_netdevice_notifier(_dev_notifier);
 out_sock:
+   dev_remove_pack(_packet_type);
sock_unregister(AF_X25);
 out_proto:
proto_unregister(_proto);
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe1..ba078c8 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@
{ },
 };
 
-void __init x25_register_sysctl(void)
+int __init x25_register_sysctl(void)
 {
x25_table_header = register_net_sysctl(_net, "net/x25", x25_table);
+   if (!x25_table_header)
+   return -ENOMEM;
+   return 0;
 }
 
 void x25_unregister_sysctl(void)
-- 
1.8.3.1



[PATCH net v2] net: x25: fix one potential use-after-free issue

2017-05-15 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add properly unregister call on error handler.

Also, i adjust the coding style and make x25_register_sysctl properly
return failure.

Signed-off-by: linzhang <xiaolou4...@gmail.com>
---
 include/net/x25.h|  4 ++--
 net/x25/af_x25.c | 34 +-
 net/x25/sysctl_net_x25.c |  5 -
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/include/net/x25.h b/include/net/x25.h
index c383aa4..339820c 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -298,10 +298,10 @@ int x25_decode(struct sock *, struct sk_buff *, int *, 
int *, int *, int *,
 
 /* sysctl_net_x25.c */
 #ifdef CONFIG_SYSCTL
-void x25_register_sysctl(void);
+int x25_register_sysctl(void);
 void x25_unregister_sysctl(void);
 #else
-static inline void x25_register_sysctl(void) {};
+static inline int x25_register_sysctl(void) { return 0 };
 static inline void x25_unregister_sysctl(void) {};
 #endif /* CONFIG_SYSCTL */
 
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..75c64de 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1791,34 +1791,42 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
 
 static int __init x25_init(void)
 {
-   int rc = proto_register(_proto, 0);
+   int rc;
 
-   if (rc != 0)
+   rc = proto_register(_proto, 0);
+   if (rc)
goto out;
 
rc = sock_register(_family_ops);
-   if (rc != 0)
-   goto out_proto;
+   if (rc)
+   goto out_sock;
 
dev_add_pack(_packet_type);
 
rc = register_netdevice_notifier(_dev_notifier);
-   if (rc != 0)
-   goto out_sock;
+   if (rc)
+   goto out_dev;
 
-   pr_info("Linux Version 0.2\n");
+   rc = x25_register_sysctl();
+   if (rc)
+   goto out_sysctl;
 
-   x25_register_sysctl();
rc = x25_proc_init();
-   if (rc != 0)
-   goto out_dev;
+   if (rc)
+   goto out_proc;
+
+   pr_info("Linux Version 0.2\n");
+
 out:
return rc;
-out_dev:
+out_proc:
+   x25_unregister_sysctl();
+out_sysctl:
unregister_netdevice_notifier(_dev_notifier);
-out_sock:
+out_dev:
+   dev_remove_pack(_packet_type);
sock_unregister(AF_X25);
-out_proto:
+out_sock:
proto_unregister(_proto);
goto out;
 }
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe1..ba078c8 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@
{ },
 };
 
-void __init x25_register_sysctl(void)
+int __init x25_register_sysctl(void)
 {
x25_table_header = register_net_sysctl(_net, "net/x25", x25_table);
+   if (!x25_table_header)
+   return -ENOMEM;
+   return 0;
 }
 
 void x25_unregister_sysctl(void)
-- 
1.8.3.1



[PATCH net v2] net: x25: fix one potential use-after-free issue

2017-05-15 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add properly unregister call on error handler.

Also, i adjust the coding style and make x25_register_sysctl properly
return failure.

Signed-off-by: linzhang 
---
 include/net/x25.h|  4 ++--
 net/x25/af_x25.c | 34 +-
 net/x25/sysctl_net_x25.c |  5 -
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/include/net/x25.h b/include/net/x25.h
index c383aa4..339820c 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -298,10 +298,10 @@ int x25_decode(struct sock *, struct sk_buff *, int *, 
int *, int *, int *,
 
 /* sysctl_net_x25.c */
 #ifdef CONFIG_SYSCTL
-void x25_register_sysctl(void);
+int x25_register_sysctl(void);
 void x25_unregister_sysctl(void);
 #else
-static inline void x25_register_sysctl(void) {};
+static inline int x25_register_sysctl(void) { return 0 };
 static inline void x25_unregister_sysctl(void) {};
 #endif /* CONFIG_SYSCTL */
 
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..75c64de 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1791,34 +1791,42 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
 
 static int __init x25_init(void)
 {
-   int rc = proto_register(_proto, 0);
+   int rc;
 
-   if (rc != 0)
+   rc = proto_register(_proto, 0);
+   if (rc)
goto out;
 
rc = sock_register(_family_ops);
-   if (rc != 0)
-   goto out_proto;
+   if (rc)
+   goto out_sock;
 
dev_add_pack(_packet_type);
 
rc = register_netdevice_notifier(_dev_notifier);
-   if (rc != 0)
-   goto out_sock;
+   if (rc)
+   goto out_dev;
 
-   pr_info("Linux Version 0.2\n");
+   rc = x25_register_sysctl();
+   if (rc)
+   goto out_sysctl;
 
-   x25_register_sysctl();
rc = x25_proc_init();
-   if (rc != 0)
-   goto out_dev;
+   if (rc)
+   goto out_proc;
+
+   pr_info("Linux Version 0.2\n");
+
 out:
return rc;
-out_dev:
+out_proc:
+   x25_unregister_sysctl();
+out_sysctl:
unregister_netdevice_notifier(_dev_notifier);
-out_sock:
+out_dev:
+   dev_remove_pack(_packet_type);
sock_unregister(AF_X25);
-out_proto:
+out_sock:
proto_unregister(_proto);
goto out;
 }
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe1..ba078c8 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@
{ },
 };
 
-void __init x25_register_sysctl(void)
+int __init x25_register_sysctl(void)
 {
x25_table_header = register_net_sysctl(_net, "net/x25", x25_table);
+   if (!x25_table_header)
+   return -ENOMEM;
+   return 0;
 }
 
 void x25_unregister_sysctl(void)
-- 
1.8.3.1



[PATCH] net: x25: fix one potential use-after-free issue

2017-05-14 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add right unregister call on error handler.

Signed-off-by: linzhang <xiaolou4...@gmail.com>
---
 net/x25/af_x25.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..e01e09a 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1811,12 +1811,14 @@ static int __init x25_init(void)
x25_register_sysctl();
rc = x25_proc_init();
if (rc != 0)
-   goto out_dev;
+   goto out_sysctl;
 out:
return rc;
-out_dev:
+out_sysctl:
+   x25_unregister_sysctl();
unregister_netdevice_notifier(_dev_notifier);
 out_sock:
+   dev_remove_pack(_packet_type);
sock_unregister(AF_X25);
 out_proto:
proto_unregister(_proto);
-- 
1.8.3.1



[PATCH] net: x25: fix one potential use-after-free issue

2017-05-14 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add right unregister call on error handler.

Signed-off-by: linzhang 
---
 net/x25/af_x25.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..e01e09a 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1811,12 +1811,14 @@ static int __init x25_init(void)
x25_register_sysctl();
rc = x25_proc_init();
if (rc != 0)
-   goto out_dev;
+   goto out_sysctl;
 out:
return rc;
-out_dev:
+out_sysctl:
+   x25_unregister_sysctl();
unregister_netdevice_notifier(_dev_notifier);
 out_sock:
+   dev_remove_pack(_packet_type);
sock_unregister(AF_X25);
 out_proto:
proto_unregister(_proto);
-- 
1.8.3.1



[PATCH] net: socket: mark socket protocol handler structs as const

2017-05-14 Thread linzhang
Signed-off-by: linzhang <xiaolou4...@gmail.com>
---
 net/bluetooth/af_bluetooth.c | 2 +-
 net/caif/caif_socket.c   | 2 +-
 net/kcm/kcmsock.c| 2 +-
 net/nfc/af_nfc.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 42d0997..8a8f77a 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -733,7 +733,7 @@ void bt_procfs_cleanup(struct net *net, const char *name)
 EXPORT_SYMBOL(bt_procfs_init);
 EXPORT_SYMBOL(bt_procfs_cleanup);
 
-static struct net_proto_family bt_sock_family_ops = {
+static const struct net_proto_family bt_sock_family_ops = {
.owner  = THIS_MODULE,
.family = PF_BLUETOOTH,
.create = bt_sock_create,
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index adcad34..4674d17 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -1099,7 +1099,7 @@ static int caif_create(struct net *net, struct socket 
*sock, int protocol,
 }
 
 
-static struct net_proto_family caif_family_ops = {
+static const struct net_proto_family caif_family_ops = {
.family = PF_CAIF,
.create = caif_create,
.owner = THIS_MODULE,
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index deca20f..da49191 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1985,7 +1985,7 @@ static int kcm_create(struct net *net, struct socket 
*sock,
return 0;
 }
 
-static struct net_proto_family kcm_family_ops = {
+static const struct net_proto_family kcm_family_ops = {
.family = PF_KCM,
.create = kcm_create,
.owner  = THIS_MODULE,
diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c
index 54e40fa..d3e594e 100644
--- a/net/nfc/af_nfc.c
+++ b/net/nfc/af_nfc.c
@@ -48,7 +48,7 @@ static int nfc_sock_create(struct net *net, struct socket 
*sock, int proto,
return rc;
 }
 
-static struct net_proto_family nfc_sock_family_ops = {
+static const struct net_proto_family nfc_sock_family_ops = {
.owner  = THIS_MODULE,
.family = PF_NFC,
.create = nfc_sock_create,
-- 
1.8.3.1



[PATCH] net: socket: mark socket protocol handler structs as const

2017-05-14 Thread linzhang
Signed-off-by: linzhang 
---
 net/bluetooth/af_bluetooth.c | 2 +-
 net/caif/caif_socket.c   | 2 +-
 net/kcm/kcmsock.c| 2 +-
 net/nfc/af_nfc.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 42d0997..8a8f77a 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -733,7 +733,7 @@ void bt_procfs_cleanup(struct net *net, const char *name)
 EXPORT_SYMBOL(bt_procfs_init);
 EXPORT_SYMBOL(bt_procfs_cleanup);
 
-static struct net_proto_family bt_sock_family_ops = {
+static const struct net_proto_family bt_sock_family_ops = {
.owner  = THIS_MODULE,
.family = PF_BLUETOOTH,
.create = bt_sock_create,
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index adcad34..4674d17 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -1099,7 +1099,7 @@ static int caif_create(struct net *net, struct socket 
*sock, int protocol,
 }
 
 
-static struct net_proto_family caif_family_ops = {
+static const struct net_proto_family caif_family_ops = {
.family = PF_CAIF,
.create = caif_create,
.owner = THIS_MODULE,
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index deca20f..da49191 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1985,7 +1985,7 @@ static int kcm_create(struct net *net, struct socket 
*sock,
return 0;
 }
 
-static struct net_proto_family kcm_family_ops = {
+static const struct net_proto_family kcm_family_ops = {
.family = PF_KCM,
.create = kcm_create,
.owner  = THIS_MODULE,
diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c
index 54e40fa..d3e594e 100644
--- a/net/nfc/af_nfc.c
+++ b/net/nfc/af_nfc.c
@@ -48,7 +48,7 @@ static int nfc_sock_create(struct net *net, struct socket 
*sock, int proto,
return rc;
 }
 
-static struct net_proto_family nfc_sock_family_ops = {
+static const struct net_proto_family nfc_sock_family_ops = {
.owner  = THIS_MODULE,
.family = PF_NFC,
.create = nfc_sock_create,
-- 
1.8.3.1



[PATCH] net: netfilter: netlink: delete extra spaces

2017-05-11 Thread linzhang
This patch cleans up extra spaces.

Signed-off-by: linzhang <xiaolou4...@gmail.com>
---
 net/netfilter/nf_conntrack_netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index dcf561b..356e6f0 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -634,11 +634,11 @@ static size_t ctnetlink_nlmsg_size(const struct nf_conn 
*ct)
if (events & (1 << IPCT_DESTROY)) {
type = IPCTNL_MSG_CT_DELETE;
group = NFNLGRP_CONNTRACK_DESTROY;
-   } else  if (events & ((1 << IPCT_NEW) | (1 << IPCT_RELATED))) {
+   } else if (events & ((1 << IPCT_NEW) | (1 << IPCT_RELATED))) {
type = IPCTNL_MSG_CT_NEW;
flags = NLM_F_CREATE|NLM_F_EXCL;
group = NFNLGRP_CONNTRACK_NEW;
-   } else  if (events) {
+   } else if (events) {
type = IPCTNL_MSG_CT_NEW;
group = NFNLGRP_CONNTRACK_UPDATE;
} else
-- 
1.8.3.1



[PATCH] net: netfilter: netlink: delete extra spaces

2017-05-11 Thread linzhang
This patch cleans up extra spaces.

Signed-off-by: linzhang 
---
 net/netfilter/nf_conntrack_netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index dcf561b..356e6f0 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -634,11 +634,11 @@ static size_t ctnetlink_nlmsg_size(const struct nf_conn 
*ct)
if (events & (1 << IPCT_DESTROY)) {
type = IPCTNL_MSG_CT_DELETE;
group = NFNLGRP_CONNTRACK_DESTROY;
-   } else  if (events & ((1 << IPCT_NEW) | (1 << IPCT_RELATED))) {
+   } else if (events & ((1 << IPCT_NEW) | (1 << IPCT_RELATED))) {
type = IPCTNL_MSG_CT_NEW;
flags = NLM_F_CREATE|NLM_F_EXCL;
group = NFNLGRP_CONNTRACK_NEW;
-   } else  if (events) {
+   } else if (events) {
type = IPCTNL_MSG_CT_NEW;
group = NFNLGRP_CONNTRACK_UPDATE;
} else
-- 
1.8.3.1