diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-16 16:14:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-16 16:14:52 -0400 |
commit | 8011652957995914272f398071b70140639185ce (patch) | |
tree | a4aa83038c3b763cce267cfec9b652795af7f420 /net | |
parent | 568b44559d7ca269d367e694c74eb4436e7e3ccf (diff) | |
parent | 26a5d3cc0b3d1ff23b5a94edb58226afe7f12a0c (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking tree from David Miller:
1) ptp_pch driver build broke during this merge window due to missing
slab.h header, fix from Geery Uytterhoeven.
2) If ipset passes in a bogus hash table size we crash because the size
is not validated properly. Compounding this, gcc-4.7 can miscompile
ipset such that even when the user specifies legitimate parameters
the tool passes in an out-of-range size to the kernel.
Fix from Jozsef Kadlecsik.
3) Users have reported that the netdev watchdog can trigger with pch_gbe
devices, and it turns out this is happening because of races in the
TX path of the driver leading to the transmitter hanging. Fix from
Eric Dumazet, reported and tested by Andy Cress.
4) Novatel USB551L devices match the generic class entries for the cdc
ethernet USB driver, but they don't work because they have generic
descriptors and thus need FLAG_WWAN to function properly.
Add the necessary ID table entry to fix this, from Dan Williams.
5) A recursive locking fix in the USBNET driver added a new problem, in
that packet list traversal is now racy and we can thus access
unlinked SKBs and crash.
Avoid this situation by adding some extra state tracking, from Ming
Lei.
6) The rtlwifi conversion to asynchronous firmware loading is racy, fix
by reordering the probe procedure. From Larry Finger.
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=43187
7) Fix regressions with bluetooth keyboards by notifying userland
properly when the security level changes, from Gustavo Padovan.
8) Bluetooth needs to make sure device connected events are emitted
before other kinds of events, otherwise userspace will think there is
no baseband link yet and therefore abort the sockets associated with
that connection.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net:
netfilter: ipset: fix hash size checking in kernel
ptp_pch: Add missing #include <linux/slab.h>
pch_gbe: fix transmit races
cdc_ether: add Novatel USB551L device IDs for FLAG_WWAN
usbnet: fix skb traversing races during unlink(v2)
Bluetooth: mgmt: Fix device_connected sending order
Bluetooth: notify userspace of security level change
rtlwifi: fix for race condition when firmware is cached
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 8 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 11 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 5 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 12 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ip.c | 10 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ipport.c | 10 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ipportip.c | 10 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ipportnet.c | 10 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_net.c | 10 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_netiface.c | 10 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_netport.c | 10 |
12 files changed, 80 insertions, 28 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 72eb187a5f60..6fb68a9743af 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -450,7 +450,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock, poll_table *wa | |||
450 | sk->sk_state == BT_CONFIG) | 450 | sk->sk_state == BT_CONFIG) |
451 | return mask; | 451 | return mask; |
452 | 452 | ||
453 | if (sock_writeable(sk)) | 453 | if (!bt_sk(sk)->suspended && sock_writeable(sk)) |
454 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; | 454 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; |
455 | else | 455 | else |
456 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); | 456 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index edfd61addcec..d6dc44cd15b0 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2784,6 +2784,14 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) | |||
2784 | if (conn) { | 2784 | if (conn) { |
2785 | hci_conn_enter_active_mode(conn, BT_POWER_FORCE_ACTIVE_OFF); | 2785 | hci_conn_enter_active_mode(conn, BT_POWER_FORCE_ACTIVE_OFF); |
2786 | 2786 | ||
2787 | hci_dev_lock(hdev); | ||
2788 | if (test_bit(HCI_MGMT, &hdev->dev_flags) && | ||
2789 | !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) | ||
2790 | mgmt_device_connected(hdev, &conn->dst, conn->type, | ||
2791 | conn->dst_type, 0, NULL, 0, | ||
2792 | conn->dev_class); | ||
2793 | hci_dev_unlock(hdev); | ||
2794 | |||
2787 | /* Send to upper protocol */ | 2795 | /* Send to upper protocol */ |
2788 | l2cap_recv_acldata(conn, skb, flags); | 2796 | l2cap_recv_acldata(conn, skb, flags); |
2789 | return; | 2797 | return; |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6c065254afc0..1266f78fa8e3 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -2039,6 +2039,12 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff * | |||
2039 | 2039 | ||
2040 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); | 2040 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); |
2041 | 2041 | ||
2042 | if (ev->status && conn->state == BT_CONNECTED) { | ||
2043 | hci_acl_disconn(conn, 0x13); | ||
2044 | hci_conn_put(conn); | ||
2045 | goto unlock; | ||
2046 | } | ||
2047 | |||
2042 | if (conn->state == BT_CONFIG) { | 2048 | if (conn->state == BT_CONFIG) { |
2043 | if (!ev->status) | 2049 | if (!ev->status) |
2044 | conn->state = BT_CONNECTED; | 2050 | conn->state = BT_CONNECTED; |
@@ -2049,6 +2055,7 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff * | |||
2049 | hci_encrypt_cfm(conn, ev->status, ev->encrypt); | 2055 | hci_encrypt_cfm(conn, ev->status, ev->encrypt); |
2050 | } | 2056 | } |
2051 | 2057 | ||
2058 | unlock: | ||
2052 | hci_dev_unlock(hdev); | 2059 | hci_dev_unlock(hdev); |
2053 | } | 2060 | } |
2054 | 2061 | ||
@@ -2102,7 +2109,7 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff | |||
2102 | goto unlock; | 2109 | goto unlock; |
2103 | } | 2110 | } |
2104 | 2111 | ||
2105 | if (!ev->status) { | 2112 | if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { |
2106 | struct hci_cp_remote_name_req cp; | 2113 | struct hci_cp_remote_name_req cp; |
2107 | memset(&cp, 0, sizeof(cp)); | 2114 | memset(&cp, 0, sizeof(cp)); |
2108 | bacpy(&cp.bdaddr, &conn->dst); | 2115 | bacpy(&cp.bdaddr, &conn->dst); |
@@ -2871,7 +2878,7 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b | |||
2871 | if (conn->state != BT_CONFIG) | 2878 | if (conn->state != BT_CONFIG) |
2872 | goto unlock; | 2879 | goto unlock; |
2873 | 2880 | ||
2874 | if (!ev->status) { | 2881 | if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { |
2875 | struct hci_cp_remote_name_req cp; | 2882 | struct hci_cp_remote_name_req cp; |
2876 | memset(&cp, 0, sizeof(cp)); | 2883 | memset(&cp, 0, sizeof(cp)); |
2877 | bacpy(&cp.bdaddr, &conn->dst); | 2884 | bacpy(&cp.bdaddr, &conn->dst); |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 94552b33d528..6f9c25b633a6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -4589,6 +4589,11 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
4589 | 4589 | ||
4590 | if (!status && (chan->state == BT_CONNECTED || | 4590 | if (!status && (chan->state == BT_CONNECTED || |
4591 | chan->state == BT_CONFIG)) { | 4591 | chan->state == BT_CONFIG)) { |
4592 | struct sock *sk = chan->sk; | ||
4593 | |||
4594 | bt_sk(sk)->suspended = false; | ||
4595 | sk->sk_state_change(sk); | ||
4596 | |||
4592 | l2cap_check_encryption(chan, encrypt); | 4597 | l2cap_check_encryption(chan, encrypt); |
4593 | l2cap_chan_unlock(chan); | 4598 | l2cap_chan_unlock(chan); |
4594 | continue; | 4599 | continue; |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 29122ed28ea9..04e7c172d49c 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -592,10 +592,14 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
592 | sk->sk_state = BT_CONFIG; | 592 | sk->sk_state = BT_CONFIG; |
593 | chan->state = BT_CONFIG; | 593 | chan->state = BT_CONFIG; |
594 | 594 | ||
595 | /* or for ACL link, under defer_setup time */ | 595 | /* or for ACL link */ |
596 | } else if (sk->sk_state == BT_CONNECT2 && | 596 | } else if ((sk->sk_state == BT_CONNECT2 && |
597 | bt_sk(sk)->defer_setup) { | 597 | bt_sk(sk)->defer_setup) || |
598 | err = l2cap_chan_check_security(chan); | 598 | sk->sk_state == BT_CONNECTED) { |
599 | if (!l2cap_chan_check_security(chan)) | ||
600 | bt_sk(sk)->suspended = true; | ||
601 | else | ||
602 | sk->sk_state_change(sk); | ||
599 | } else { | 603 | } else { |
600 | err = -EINVAL; | 604 | err = -EINVAL; |
601 | } | 605 | } |
diff --git a/net/netfilter/ipset/ip_set_hash_ip.c b/net/netfilter/ipset/ip_set_hash_ip.c index 5139dea6019e..828ce46cb34b 100644 --- a/net/netfilter/ipset/ip_set_hash_ip.c +++ b/net/netfilter/ipset/ip_set_hash_ip.c | |||
@@ -364,6 +364,7 @@ hash_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
364 | { | 364 | { |
365 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 365 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
366 | u8 netmask, hbits; | 366 | u8 netmask, hbits; |
367 | size_t hsize; | ||
367 | struct ip_set_hash *h; | 368 | struct ip_set_hash *h; |
368 | 369 | ||
369 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 370 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
@@ -405,9 +406,12 @@ hash_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
405 | h->timeout = IPSET_NO_TIMEOUT; | 406 | h->timeout = IPSET_NO_TIMEOUT; |
406 | 407 | ||
407 | hbits = htable_bits(hashsize); | 408 | hbits = htable_bits(hashsize); |
408 | h->table = ip_set_alloc( | 409 | hsize = htable_size(hbits); |
409 | sizeof(struct htable) | 410 | if (hsize == 0) { |
410 | + jhash_size(hbits) * sizeof(struct hbucket)); | 411 | kfree(h); |
412 | return -ENOMEM; | ||
413 | } | ||
414 | h->table = ip_set_alloc(hsize); | ||
411 | if (!h->table) { | 415 | if (!h->table) { |
412 | kfree(h); | 416 | kfree(h); |
413 | return -ENOMEM; | 417 | return -ENOMEM; |
diff --git a/net/netfilter/ipset/ip_set_hash_ipport.c b/net/netfilter/ipset/ip_set_hash_ipport.c index 9c27e249c171..e8dbb498af8f 100644 --- a/net/netfilter/ipset/ip_set_hash_ipport.c +++ b/net/netfilter/ipset/ip_set_hash_ipport.c | |||
@@ -449,6 +449,7 @@ hash_ipport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
449 | struct ip_set_hash *h; | 449 | struct ip_set_hash *h; |
450 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 450 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
451 | u8 hbits; | 451 | u8 hbits; |
452 | size_t hsize; | ||
452 | 453 | ||
453 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 454 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
454 | return -IPSET_ERR_INVALID_FAMILY; | 455 | return -IPSET_ERR_INVALID_FAMILY; |
@@ -476,9 +477,12 @@ hash_ipport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
476 | h->timeout = IPSET_NO_TIMEOUT; | 477 | h->timeout = IPSET_NO_TIMEOUT; |
477 | 478 | ||
478 | hbits = htable_bits(hashsize); | 479 | hbits = htable_bits(hashsize); |
479 | h->table = ip_set_alloc( | 480 | hsize = htable_size(hbits); |
480 | sizeof(struct htable) | 481 | if (hsize == 0) { |
481 | + jhash_size(hbits) * sizeof(struct hbucket)); | 482 | kfree(h); |
483 | return -ENOMEM; | ||
484 | } | ||
485 | h->table = ip_set_alloc(hsize); | ||
482 | if (!h->table) { | 486 | if (!h->table) { |
483 | kfree(h); | 487 | kfree(h); |
484 | return -ENOMEM; | 488 | return -ENOMEM; |
diff --git a/net/netfilter/ipset/ip_set_hash_ipportip.c b/net/netfilter/ipset/ip_set_hash_ipportip.c index 9134057c0728..52f79d8ef741 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportip.c +++ b/net/netfilter/ipset/ip_set_hash_ipportip.c | |||
@@ -467,6 +467,7 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
467 | struct ip_set_hash *h; | 467 | struct ip_set_hash *h; |
468 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 468 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
469 | u8 hbits; | 469 | u8 hbits; |
470 | size_t hsize; | ||
470 | 471 | ||
471 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 472 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
472 | return -IPSET_ERR_INVALID_FAMILY; | 473 | return -IPSET_ERR_INVALID_FAMILY; |
@@ -494,9 +495,12 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
494 | h->timeout = IPSET_NO_TIMEOUT; | 495 | h->timeout = IPSET_NO_TIMEOUT; |
495 | 496 | ||
496 | hbits = htable_bits(hashsize); | 497 | hbits = htable_bits(hashsize); |
497 | h->table = ip_set_alloc( | 498 | hsize = htable_size(hbits); |
498 | sizeof(struct htable) | 499 | if (hsize == 0) { |
499 | + jhash_size(hbits) * sizeof(struct hbucket)); | 500 | kfree(h); |
501 | return -ENOMEM; | ||
502 | } | ||
503 | h->table = ip_set_alloc(hsize); | ||
500 | if (!h->table) { | 504 | if (!h->table) { |
501 | kfree(h); | 505 | kfree(h); |
502 | return -ENOMEM; | 506 | return -ENOMEM; |
diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c index 5d05e6969862..97583f5af745 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportnet.c +++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c | |||
@@ -616,6 +616,7 @@ hash_ipportnet_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
616 | struct ip_set_hash *h; | 616 | struct ip_set_hash *h; |
617 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 617 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
618 | u8 hbits; | 618 | u8 hbits; |
619 | size_t hsize; | ||
619 | 620 | ||
620 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 621 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
621 | return -IPSET_ERR_INVALID_FAMILY; | 622 | return -IPSET_ERR_INVALID_FAMILY; |
@@ -645,9 +646,12 @@ hash_ipportnet_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
645 | h->timeout = IPSET_NO_TIMEOUT; | 646 | h->timeout = IPSET_NO_TIMEOUT; |
646 | 647 | ||
647 | hbits = htable_bits(hashsize); | 648 | hbits = htable_bits(hashsize); |
648 | h->table = ip_set_alloc( | 649 | hsize = htable_size(hbits); |
649 | sizeof(struct htable) | 650 | if (hsize == 0) { |
650 | + jhash_size(hbits) * sizeof(struct hbucket)); | 651 | kfree(h); |
652 | return -ENOMEM; | ||
653 | } | ||
654 | h->table = ip_set_alloc(hsize); | ||
651 | if (!h->table) { | 655 | if (!h->table) { |
652 | kfree(h); | 656 | kfree(h); |
653 | return -ENOMEM; | 657 | return -ENOMEM; |
diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c index 7c3d945517cf..1721cdecc9f9 100644 --- a/net/netfilter/ipset/ip_set_hash_net.c +++ b/net/netfilter/ipset/ip_set_hash_net.c | |||
@@ -460,6 +460,7 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
460 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 460 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
461 | struct ip_set_hash *h; | 461 | struct ip_set_hash *h; |
462 | u8 hbits; | 462 | u8 hbits; |
463 | size_t hsize; | ||
463 | 464 | ||
464 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 465 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
465 | return -IPSET_ERR_INVALID_FAMILY; | 466 | return -IPSET_ERR_INVALID_FAMILY; |
@@ -489,9 +490,12 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
489 | h->timeout = IPSET_NO_TIMEOUT; | 490 | h->timeout = IPSET_NO_TIMEOUT; |
490 | 491 | ||
491 | hbits = htable_bits(hashsize); | 492 | hbits = htable_bits(hashsize); |
492 | h->table = ip_set_alloc( | 493 | hsize = htable_size(hbits); |
493 | sizeof(struct htable) | 494 | if (hsize == 0) { |
494 | + jhash_size(hbits) * sizeof(struct hbucket)); | 495 | kfree(h); |
496 | return -ENOMEM; | ||
497 | } | ||
498 | h->table = ip_set_alloc(hsize); | ||
495 | if (!h->table) { | 499 | if (!h->table) { |
496 | kfree(h); | 500 | kfree(h); |
497 | return -ENOMEM; | 501 | return -ENOMEM; |
diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c index f24037ff4322..33bafc97ca6d 100644 --- a/net/netfilter/ipset/ip_set_hash_netiface.c +++ b/net/netfilter/ipset/ip_set_hash_netiface.c | |||
@@ -722,6 +722,7 @@ hash_netiface_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
722 | struct ip_set_hash *h; | 722 | struct ip_set_hash *h; |
723 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 723 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
724 | u8 hbits; | 724 | u8 hbits; |
725 | size_t hsize; | ||
725 | 726 | ||
726 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 727 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
727 | return -IPSET_ERR_INVALID_FAMILY; | 728 | return -IPSET_ERR_INVALID_FAMILY; |
@@ -752,9 +753,12 @@ hash_netiface_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
752 | h->ahash_max = AHASH_MAX_SIZE; | 753 | h->ahash_max = AHASH_MAX_SIZE; |
753 | 754 | ||
754 | hbits = htable_bits(hashsize); | 755 | hbits = htable_bits(hashsize); |
755 | h->table = ip_set_alloc( | 756 | hsize = htable_size(hbits); |
756 | sizeof(struct htable) | 757 | if (hsize == 0) { |
757 | + jhash_size(hbits) * sizeof(struct hbucket)); | 758 | kfree(h); |
759 | return -ENOMEM; | ||
760 | } | ||
761 | h->table = ip_set_alloc(hsize); | ||
758 | if (!h->table) { | 762 | if (!h->table) { |
759 | kfree(h); | 763 | kfree(h); |
760 | return -ENOMEM; | 764 | return -ENOMEM; |
diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c index ce2e77100b64..3a5e198641d6 100644 --- a/net/netfilter/ipset/ip_set_hash_netport.c +++ b/net/netfilter/ipset/ip_set_hash_netport.c | |||
@@ -572,6 +572,7 @@ hash_netport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
572 | struct ip_set_hash *h; | 572 | struct ip_set_hash *h; |
573 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; | 573 | u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; |
574 | u8 hbits; | 574 | u8 hbits; |
575 | size_t hsize; | ||
575 | 576 | ||
576 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) | 577 | if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) |
577 | return -IPSET_ERR_INVALID_FAMILY; | 578 | return -IPSET_ERR_INVALID_FAMILY; |
@@ -601,9 +602,12 @@ hash_netport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
601 | h->timeout = IPSET_NO_TIMEOUT; | 602 | h->timeout = IPSET_NO_TIMEOUT; |
602 | 603 | ||
603 | hbits = htable_bits(hashsize); | 604 | hbits = htable_bits(hashsize); |
604 | h->table = ip_set_alloc( | 605 | hsize = htable_size(hbits); |
605 | sizeof(struct htable) | 606 | if (hsize == 0) { |
606 | + jhash_size(hbits) * sizeof(struct hbucket)); | 607 | kfree(h); |
608 | return -ENOMEM; | ||
609 | } | ||
610 | h->table = ip_set_alloc(hsize); | ||
607 | if (!h->table) { | 611 | if (!h->table) { |
608 | kfree(h); | 612 | kfree(h); |
609 | return -ENOMEM; | 613 | return -ENOMEM; |