aboutsummaryrefslogtreecommitdiffstats
path: root/net/can
diff options
context:
space:
mode:
Diffstat (limited to 'net/can')
-rw-r--r--net/can/af_can.c20
-rw-r--r--net/can/bcm.c9
-rw-r--r--net/can/raw.c5
3 files changed, 13 insertions, 21 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 606832115674..51adc4c2b860 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -114,7 +114,8 @@ static void can_sock_destruct(struct sock *sk)
114 skb_queue_purge(&sk->sk_receive_queue); 114 skb_queue_purge(&sk->sk_receive_queue);
115} 115}
116 116
117static int can_create(struct net *net, struct socket *sock, int protocol) 117static int can_create(struct net *net, struct socket *sock, int protocol,
118 int kern)
118{ 119{
119 struct sock *sk; 120 struct sock *sk;
120 struct can_proto *cp; 121 struct can_proto *cp;
@@ -125,7 +126,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
125 if (protocol < 0 || protocol >= CAN_NPROTO) 126 if (protocol < 0 || protocol >= CAN_NPROTO)
126 return -EINVAL; 127 return -EINVAL;
127 128
128 if (net != &init_net) 129 if (!net_eq(net, &init_net))
129 return -EAFNOSUPPORT; 130 return -EAFNOSUPPORT;
130 131
131#ifdef CONFIG_MODULES 132#ifdef CONFIG_MODULES
@@ -160,11 +161,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
160 goto errout; 161 goto errout;
161 } 162 }
162 163
163 if (cp->capability >= 0 && !capable(cp->capability)) {
164 err = -EPERM;
165 goto errout;
166 }
167
168 sock->ops = cp->ops; 164 sock->ops = cp->ops;
169 165
170 sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot); 166 sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot);
@@ -379,8 +375,8 @@ static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
379 return &d->rx[RX_ALL]; 375 return &d->rx[RX_ALL];
380 376
381 /* extra filterlists for the subscription of a single non-RTR can_id */ 377 /* extra filterlists for the subscription of a single non-RTR can_id */
382 if (((*mask & CAN_EFF_RTR_FLAGS) == CAN_EFF_RTR_FLAGS) 378 if (((*mask & CAN_EFF_RTR_FLAGS) == CAN_EFF_RTR_FLAGS) &&
383 && !(*can_id & CAN_RTR_FLAG)) { 379 !(*can_id & CAN_RTR_FLAG)) {
384 380
385 if (*can_id & CAN_EFF_FLAG) { 381 if (*can_id & CAN_EFF_FLAG) {
386 if (*mask == (CAN_EFF_MASK | CAN_EFF_RTR_FLAGS)) { 382 if (*mask == (CAN_EFF_MASK | CAN_EFF_RTR_FLAGS)) {
@@ -529,8 +525,8 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
529 */ 525 */
530 526
531 hlist_for_each_entry_rcu(r, next, rl, list) { 527 hlist_for_each_entry_rcu(r, next, rl, list) {
532 if (r->can_id == can_id && r->mask == mask 528 if (r->can_id == can_id && r->mask == mask &&
533 && r->func == func && r->data == data) 529 r->func == func && r->data == data)
534 break; 530 break;
535 } 531 }
536 532
@@ -842,7 +838,7 @@ static struct packet_type can_packet __read_mostly = {
842 .func = can_rcv, 838 .func = can_rcv,
843}; 839};
844 840
845static struct net_proto_family can_family_ops __read_mostly = { 841static const struct net_proto_family can_family_ops = {
846 .family = PF_CAN, 842 .family = PF_CAN,
847 .create = can_create, 843 .create = can_create,
848 .owner = THIS_MODULE, 844 .owner = THIS_MODULE,
diff --git a/net/can/bcm.c b/net/can/bcm.c
index e8d58f33fe09..e32af52238a2 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -139,13 +139,13 @@ static char *bcm_proc_getifname(char *result, int ifindex)
139 if (!ifindex) 139 if (!ifindex)
140 return "any"; 140 return "any";
141 141
142 read_lock(&dev_base_lock); 142 rcu_read_lock();
143 dev = __dev_get_by_index(&init_net, ifindex); 143 dev = dev_get_by_index_rcu(&init_net, ifindex);
144 if (dev) 144 if (dev)
145 strcpy(result, dev->name); 145 strcpy(result, dev->name);
146 else 146 else
147 strcpy(result, "???"); 147 strcpy(result, "???");
148 read_unlock(&dev_base_lock); 148 rcu_read_unlock();
149 149
150 return result; 150 return result;
151} 151}
@@ -1539,7 +1539,7 @@ static int bcm_recvmsg(struct kiocb *iocb, struct socket *sock,
1539 return err; 1539 return err;
1540 } 1540 }
1541 1541
1542 sock_recv_timestamp(msg, sk, skb); 1542 sock_recv_ts_and_drops(msg, sk, skb);
1543 1543
1544 if (msg->msg_name) { 1544 if (msg->msg_name) {
1545 msg->msg_namelen = sizeof(struct sockaddr_can); 1545 msg->msg_namelen = sizeof(struct sockaddr_can);
@@ -1581,7 +1581,6 @@ static struct proto bcm_proto __read_mostly = {
1581static struct can_proto bcm_can_proto __read_mostly = { 1581static struct can_proto bcm_can_proto __read_mostly = {
1582 .type = SOCK_DGRAM, 1582 .type = SOCK_DGRAM,
1583 .protocol = CAN_BCM, 1583 .protocol = CAN_BCM,
1584 .capability = -1,
1585 .ops = &bcm_ops, 1584 .ops = &bcm_ops,
1586 .prot = &bcm_proto, 1585 .prot = &bcm_proto,
1587}; 1586};
diff --git a/net/can/raw.c b/net/can/raw.c
index b5e897922d32..abca920440b5 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -424,8 +424,6 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
424 424
425 if (level != SOL_CAN_RAW) 425 if (level != SOL_CAN_RAW)
426 return -EINVAL; 426 return -EINVAL;
427 if (optlen < 0)
428 return -EINVAL;
429 427
430 switch (optname) { 428 switch (optname) {
431 429
@@ -702,7 +700,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct socket *sock,
702 return err; 700 return err;
703 } 701 }
704 702
705 sock_recv_timestamp(msg, sk, skb); 703 sock_recv_ts_and_drops(msg, sk, skb);
706 704
707 if (msg->msg_name) { 705 if (msg->msg_name) {
708 msg->msg_namelen = sizeof(struct sockaddr_can); 706 msg->msg_namelen = sizeof(struct sockaddr_can);
@@ -744,7 +742,6 @@ static struct proto raw_proto __read_mostly = {
744static struct can_proto raw_can_proto __read_mostly = { 742static struct can_proto raw_can_proto __read_mostly = {
745 .type = SOCK_RAW, 743 .type = SOCK_RAW,
746 .protocol = CAN_RAW, 744 .protocol = CAN_RAW,
747 .capability = -1,
748 .ops = &raw_ops, 745 .ops = &raw_ops,
749 .prot = &raw_proto, 746 .prot = &raw_proto,
750}; 747};