3.2.87-rc1 review
Subsystems (5)
PATCH 186/199 can: Fix kernel panic at security_sock_rcv_skb
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit f1712c73714088a7252d276a57126d56c7d37e64 ]
Zhang Yanmin reported crashes [1] and provided a patch adding a synchronize_rcu() call in can_rx_unregister()
The main problem seems that the sockets themselves are not RCU protected.
If CAN uses RCU for delivery, then sockets should be freed only after one RCU grace period.
Recent kernels could use sock_set_flag(sk, SOCK_RCU_FREE), but let's ease stable backports with the following fix instead.
[1]
BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff81495e25>] selinux_socket_sock_rcv_skb+0x65/0x2a0 Call Trace: <IRQ> [<ffffffff81485d8c>] security_sock_rcv_skb+0x4c/0x60 [<ffffffff81d55771>] sk_filter+0x41/0x210 [<ffffffff81d12913>] sock_queue_rcv_skb+0x53/0x3a0 [<ffffffff81f0a2b3>] raw_rcv+0x2a3/0x3c0 [<ffffffff81f06eab>] can_rcv_filter+0x12b/0x370 [<ffffffff81f07af9>] can_receive+0xd9/0x120 [<ffffffff81f07beb>] can_rcv+0xab/0x100 [<ffffffff81d362ac>] __netif_receive_skb_core+0xd8c/0x11f0 [<ffffffff81d36734>] __netif_receive_skb+0x24/0xb0 [<ffffffff81d37f67>] process_backlog+0x127/0x280 [<ffffffff81d36f7b>] net_rx_action+0x33b/0x4f0 [<ffffffff810c88d4>] __do_softirq+0x184/0x440 [<ffffffff81f9e86c>] do_softirq_own_stack+0x1c/0x30 <EOI> [<ffffffff810c76fb>] do_softirq.part.18+0x3b/0x40 [<ffffffff810c8bed>] do_softirq+0x1d/0x20 [<ffffffff81d30085>] netif_rx_ni+0xe5/0x110 [<ffffffff8199cc87>] slcan_receive_buf+0x507/0x520 [<ffffffff8167ef7c>] flush_to_ldisc+0x21c/0x230 [<ffffffff810e3baf>] process_one_work+0x24f/0x670 [<ffffffff810e44ed>] worker_thread+0x9d/0x6f0 [<ffffffff810e4450>] ? rescuer_thread+0x480/0x480 [<ffffffff810ebafc>] kthread+0x12c/0x150 [<ffffffff81f9ccef>] ret_from_fork+0x3f/0x70
--- include/linux/can/core.h | 7 +++---- net/can/af_can.c | 12 ++++++++++-- net/can/af_can.h | 3 ++- net/can/bcm.c | 4 ++-- net/can/gw.c | 2 +- net/can/raw.c | 4 ++-- 6 files changed, 20 insertions(+), 12 deletions(-)
include/linux/can/core.h +3 -4
@@ -45,10 +45,9 @@ struct can_proto {extern int can_proto_register (const struct can_proto *cp);extern void can_proto_unregister (const struct can_proto *cp); -extern int can_rx_register (struct net_device *dev,canid_t can_id, -canid_t mask, -void (*func)(struct sk_buff *,void *), -void *data,char *ident); +int can_rx_register (struct net_device *dev,canid_t can_id,canid_t mask, +void (*func)(struct sk_buff *,void *), +void *data,char *ident,struct sock *sk); extern void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
net/can/af_can.c +10 -2
@@ -403,6 +403,7 @@ static struct hlist_head *find_rcv_list(* @func: callback function on filter match * @data: returned parameter for callback function * @ident: string for calling module indentification +* @sk: socket pointer (might be NULL) * * Description: * Invokes the callback function with the received sk_buff and the given
@@ -426,7 +427,7 @@ static struct hlist_head *find_rcv_list(*/ int can_rx_register (struct net_device *dev,canid_t can_id,canid_t mask,void (*func)(struct sk_buff *,void *),void *data, -char *ident) +char *ident,struct sock *sk) {struct receiver *r;struct hlist_head *rl;
@@ -454,6 +455,7 @@ int can_rx_register(struct net_device *d r->func = func; r->data = data; r->ident = ident; + r->sk = sk;hlist_add_head_rcu (&r->list, rl); d->entries++;
@@ -478,8 +480,11 @@ EXPORT_SYMBOL(can_rx_register);static void can_rx_delete_receiver (struct rcu_head *rp) { struct receiver *r = container_of(rp, struct receiver, rcu); +struct sock *sk = r->sk;kmem_cache_free (rcv_cache, r); +if (sk) +sock_put (sk); }/**
@@ -558,8 +563,11 @@ void can_rx_unregister(struct net_devicespin_unlock (&can_rcvlists_lock);/* schedule the receiver item for deletion */ -if (r) +if (r) { +if (r->sk) +sock_hold (r->sk);call_rcu (&r->rcu, can_rx_delete_receiver); + } }EXPORT_SYMBOL (can_rx_unregister);
net/can/af_can.h +2 -1
@@ -50,13 +50,14 @@struct receiver {struct hlist_node list; -struct rcu_head rcu;canid_t can_id;canid_t mask;unsigned long matches;void (*func)(struct sk_buff *,void *);void *data;char *ident; +struct sock *sk; +struct rcu_head rcu; };enum {RX_ERR ,RX_ALL ,RX_FIL ,RX_INV ,RX_EFF ,RX_MAX };
net/can/bcm.c +2 -2
@@ -1174,7 +1174,7 @@ static int bcm_rx_setup(struct bcm_msg_h err =can_rx_register (dev, op->can_id,REGMASK (op->can_id), bcm_rx_handler, op, -"bcm" ); +"bcm" , sk); op->rx_reg_dev = dev;dev_put (dev);
@@ -1183,7 +1183,7 @@ static int bcm_rx_setup(struct bcm_msg_h }else err =can_rx_register (NULL , op->can_id,REGMASK (op->can_id), - bcm_rx_handler, op,"bcm" ); + bcm_rx_handler, op,"bcm" , sk);if (err) {/* this bcm rx op is broken -> remove it */ list_del (&op->list);
net/can/gw.c +1 -1
@@ -405,7 +405,7 @@ static inline int cgw_register_filter(st {return can_rx_register (gwj->src.dev, gwj->ccgw.filter.can_id, gwj->ccgw.filter.can_mask, can_can_gw_rcv, - gwj,"gw" ); + gwj,"gw" ,NULL ); }static inline void cgw_unregister_filter (struct cgw_job *gwj)
net/can/raw.c +2 -2
@@ -158,7 +158,7 @@ static int raw_enable_filters(struct netfor (i =0 ; i < count; i++) { err =can_rx_register (dev, filter[i].can_id, filter[i].can_mask, - raw_rcv, sk,"raw" ); + raw_rcv, sk,"raw" , sk);if (err) {/* clean up successfully registered filters */ while (--i >=0 )
@@ -179,7 +179,7 @@ static int raw_enable_errfilter(struct nif (err_mask) err =can_rx_register (dev,0 , err_mask |CAN_ERR_FLAG , - raw_rcv, sk,"raw" ); + raw_rcv, sk,"raw" , sk);return err; }
PATCH 187/199 ipv6: fix ip6_tnl_parse_tlv_enc_lim()
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit fbfa743a9d2a0ffa24251764f10afc13eb21e739 ]
This function suffers from multiple issues.
First one is that pskb_may_pull() may reallocate skb->head, so the 'raw' pointer needs either to be reloaded or not used at all.
Second issue is that NEXTHDR_DEST handling does not validate that the options are present in skb->data, so we might read garbage or access non existent memory.
With help from Willem de Bruijn.
--- net/ipv6/ip6_tunnel.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
net/ipv6/ip6_tunnel.c +22 -12
@@ -372,18 +372,19 @@ ip6_tnl_dev_uninit(struct net_device *destatic __u16 parse_tlv_tnl_enc_lim (struct sk_buff *skb,__u8 * raw) { -const struct ipv6hdr *ipv6h = (const struct ipv6hdr *) raw; -__u8 nexthdr = ipv6h->nexthdr; -__u16 off =sizeof (*ipv6h); +const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)raw; +unsigned int nhoff = raw - skb->data; +unsigned int off = nhoff +sizeof (*ipv6h); +u8 next, nexthdr = ipv6h->nexthdr;while (ipv6_ext_hdr (nexthdr) && nexthdr !=NEXTHDR_NONE ) { -__u16 optlen =0 ;struct ipv6_opt_hdr *hdr; -if (raw + off +sizeof (*hdr) > skb->data && - !pskb_may_pull (skb, raw - skb->data + off +sizeof (*hdr))) +u16 optlen; + +if (!pskb_may_pull (skb, off +sizeof (*hdr)))break ; - hdr = (struct ipv6_opt_hdr *) (raw + off); + hdr = (struct ipv6_opt_hdr *)(skb->data + off);if (nexthdr ==NEXTHDR_FRAGMENT ) {struct frag_hdr *frag_hdr = (struct frag_hdr *) hdr;if (frag_hdr->frag_off)
@@ -394,20 +395,29 @@ parse_tlv_tnl_enc_lim(struct sk_buff *sk }else { optlen =ipv6_optlen (hdr); } +/* cache hdr->nexthdr, since pskb_may_pull() might +* invalidate hdr +*/ + next = hdr->nexthdr;if (nexthdr ==NEXTHDR_DEST ) { -__u16 i = off +2 ; +u16 i =2 ; + +/* Remember : hdr is no longer valid at this point. */ +if (!pskb_may_pull (skb, off + optlen)) +break ; +while (1 ) {struct ipv6_tlv_tnl_enc_lim *tel;/* No more room for encapsulation limit */ -if (i +sizeof (*tel) > off + optlen) +if (i +sizeof (*tel) > optlen)break ; - tel = (struct ipv6_tlv_tnl_enc_lim *) &raw[i]; + tel = (struct ipv6_tlv_tnl_enc_lim *) skb->data + off + i;/* return index of option if found and valid */ if (tel->type ==IPV6_TLV_TNL_ENCAP_LIMIT && tel->length ==1 ) -return i; +return i + off - nhoff;/* else jump to next option */ if (tel->type) i += tel->length +2 ;
@@ -415,7 +425,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *sk i++; } } - nexthdr = hdr->nexthdr; + nexthdr = next; off += optlen; }return 0 ;
PATCH 188/199 ipv6: pointer math error in ip6_tnl_parse_tlv_enc_lim()
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 63117f09c768be05a0bf465911297dc76394f686 ]
Casting is a high precedence operation but "off" and "i" are in terms of bytes so we need to have some parenthesis here.
--- net/ipv6/ip6_tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_tunnel.c +1 -1
@@ -413,7 +413,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *skif (i +sizeof (*tel) > optlen)break ; - tel = (struct ipv6_tlv_tnl_enc_lim *) skb->data + off + i; + tel = (struct ipv6_tlv_tnl_enc_lim *)(skb->data + off + i);/* return index of option if found and valid */ if (tel->type ==IPV6_TLV_TNL_ENCAP_LIMIT && tel->length ==1 )
PATCH 189/199 tcp: fix 0 divide in __tcp_select_window()
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 06425c308b92eaf60767bc71d359f4cbc7a561f8 ]
syszkaller fuzzer was able to trigger a divide by zero, when TCP window scaling is not enabled.
SO_RCVBUF can be used not only to increase sk_rcvbuf, also to decrease it below current receive buffers utilization.
If mss is negative or 0, just return a zero TCP window.
--- net/ipv4/tcp_output.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +4 -2
@@ -1923,9 +1923,11 @@ u32 __tcp_select_window(struct sock *sk)int full_space =min_t (int, tp->window_clamp,tcp_full_space (sk));int window; -if (mss > full_space) +if (unlikely (mss > full_space)) { mss = full_space; - +if (mss <=0 ) +return 0 ; + }if (free_space < (full_space >>1 )) { icsk->icsk_ack.quick =0 ;
PATCH 190/199 tun: Fix TUN_PKT_STRIP setting
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 2eb783c43e7cf807a45899c10ed556b6dc116625 upstream.
We set the flag TUN_PKT_STRIP if the user buffer provided is too small to contain the entire packet plus meta-data. However, this has been broken ever since we added GSO meta-data. VLAN acceleration also has the same problem.
This patch fixes this by taking both into account when setting the TUN_PKT_STRIP flag.
The fact that this has been broken for six years without anyone realising means that nobody actually uses this flag.
[bwh: Backported to 3.2:
- No VLAN acceleration support
- Adjust context]
--- drivers/net/tun.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/tun.c +8 -4
@@ -767,12 +767,16 @@ static ssize_t tun_put_user(struct tun_s {struct tun_pi pi = {0 , skb->protocol };ssize_t total =0 ; +int vnet_hdr_sz =0 ; + +if (tun->flags &TUN_VNET_HDR ) + vnet_hdr_sz = tun->vnet_hdr_sz;if (!(tun->flags &TUN_NO_PI )) {if ((len -=sizeof (pi)) <0 )return -EINVAL ; -if (len < skb->len) { +if (len < skb->len + vnet_hdr_sz) {/* Packet will be striped */ pi.flags |=TUN_PKT_STRIP ; }
@@ -782,9 +786,9 @@ static ssize_t tun_put_user(struct tun_s total +=sizeof (pi); } -if (tun->flags &TUN_VNET_HDR ) { +if (vnet_hdr_sz) {struct virtio_net_hdr gso = {0 };/* no info leak */ -if ((len -= tun->vnet_hdr_sz) <0 ) +if ((len -= vnet_hdr_sz) <0 )return -EINVAL ;if (skb_is_gso (skb)) {
@@ -827,7 +831,7 @@ static ssize_t tun_put_user(struct tun_sif (unlikely (memcpy_toiovecend (iv, (void *)&gso, total,sizeof (gso))))return -EFAULT ; - total += tun->vnet_hdr_sz; + total += vnet_hdr_sz; } len =min_t (int, skb->len, len);
PATCH 191/199 tun: read vnet_hdr_sz once
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit e1edab87faf6ca30cd137e0795bc73aa9a9a22ec ]
When IFF_VNET_HDR is enabled, a virtio_net header must precede data. Data length is verified to be greater than or equal to expected header length tun->vnet_hdr_sz before copying.
Read this value once and cache locally, as it can be updated between the test and use (TOCTOU).
[bwh: Backported to 3.2:
- Use ACCESS_ONCE() instead of READ_ONCE()
- Adjust context]
--- drivers/net/tun.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/tun.c +6 -4
@@ -625,9 +625,11 @@ static ssize_t tun_get_user(struct tun_s }if (tun->flags &TUN_VNET_HDR ) { -if (len < tun->vnet_hdr_sz) +int vnet_hdr_sz =ACCESS_ONCE (tun->vnet_hdr_sz); + +if (len < vnet_hdr_sz)return -EINVAL ; - len -= tun->vnet_hdr_sz; + len -= vnet_hdr_sz;if (memcpy_fromiovecend ((void *)&gso, iv, offset,sizeof (gso)))return -EFAULT ;
@@ -638,7 +640,7 @@ static ssize_t tun_get_user(struct tun_sif (gso.hdr_len > len)return -EINVAL ; - offset += tun->vnet_hdr_sz; + offset += vnet_hdr_sz; }if ((tun->flags &TUN_TYPE_MASK ) ==TUN_TAP_DEV ) {
@@ -770,7 +772,7 @@ static ssize_t tun_put_user(struct tun_sint vnet_hdr_sz =0 ;if (tun->flags &TUN_VNET_HDR ) - vnet_hdr_sz = tun->vnet_hdr_sz; + vnet_hdr_sz =ACCESS_ONCE (tun->vnet_hdr_sz);if (!(tun->flags &TUN_NO_PI )) {if ((len -=sizeof (pi)) <0 )
PATCH 192/199 macvtap: read vnet_hdr_size once
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit 837585a5375c38d40361cfe64e6fd11e1addb936 ]
When IFF_VNET_HDR is enabled, a virtio_net header must precede data. Data length is verified to be greater than or equal to expected header length tun->vnet_hdr_sz before copying.
Macvtap functions read the value once, but unless READ_ONCE is used, the compiler may ignore this and read multiple times. Enforce a single read and locally cached value to avoid updates between test and use.
[bwh: BAckported to 3.2:
- Use ACCESS_ONCE() instead of READ_ONCE()
- Adjust context]
--- drivers/net/macvtap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/macvtap.c +2 -2
@@ -687,7 +687,7 @@ static ssize_t macvtap_get_user(struct msize_t linear;if (q->flags &IFF_VNET_HDR ) { - vnet_hdr_len = q->vnet_hdr_sz; + vnet_hdr_len =ACCESS_ONCE (q->vnet_hdr_sz); err = -EINVAL ;if (len < vnet_hdr_len)
@@ -817,7 +817,7 @@ static ssize_t macvtap_put_user(struct mif (q->flags &IFF_VNET_HDR ) {struct virtio_net_hdr vnet_hdr; - vnet_hdr_len = q->vnet_hdr_sz; + vnet_hdr_len =ACCESS_ONCE (q->vnet_hdr_sz);if ((len -= vnet_hdr_len) <0 )return -EINVAL ;
PATCH 193/199 igmp: do not remove igmp souce list info when set link down
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
commit 24803f38a5c0b6c57ed800b47e695f9ce474bc3a upstream.
In commit 24cf3af3fed5 ("igmp: call ip_mc_clear_src..."), we forgot to remove igmpv3_clear_delrec() in ip_mc_down(), which also called ip_mc_clear_src(). This make us clear all IGMPv3 source filter info after NETDEV_DOWN. Move igmpv3_clear_delrec() to ip_mc_destroy_dev() and then no need ip_mc_clear_src() in ip_mc_destroy_dev().
On the other hand, we should restore back instead of free all source filter info in igmpv3_del_delrec(). Or we will not able to restore IGMPv3 source filter info after NETDEV_UP and NETDEV_POST_TYPE_CHANGE.
[bwh: Backported to 3.2:
- Use IGMP_Unsolicited_Report_Count instead of sysctl_igmp_qrv
- Adjust context]
---
net/ipv4/igmp.c +35 -14
@@ -140,7 +140,7 @@ time_before(jiffies, (in_dev)->mr_v2_seen)))static void igmpv3_add_delrec (struct in_device *in_dev,struct ip_mc_list *im); -static void igmpv3_del_delrec (struct in_device *in_dev,__be32 multiaddr); +static void igmpv3_del_delrec (struct in_device *in_dev,struct ip_mc_list *im);static void igmpv3_clear_delrec (struct in_device *in_dev);static int sf_setstate (struct ip_mc_list *pmc);static void sf_markstate (struct ip_mc_list *pmc);
@@ -1082,10 +1082,14 @@ static void igmpv3_add_delrec(struct in_spin_unlock_bh (&in_dev->mc_tomb_lock); } -static void igmpv3_del_delrec (struct in_device *in_dev,__be32 multiaddr) +/* +* restore ip_mc_list deleted records +*/ +static void igmpv3_del_delrec (struct in_device *in_dev,struct ip_mc_list *im) {struct ip_mc_list *pmc, *pmc_prev; -struct ip_sf_list *psf, *psf_next; +struct ip_sf_list *psf; +__be32 multiaddr = im->multiaddr;spin_lock_bh (&in_dev->mc_tomb_lock); pmc_prev =NULL ;
@@ -1101,16 +1105,26 @@ static void igmpv3_del_delrec(struct in_ in_dev->mc_tomb = pmc->next; }spin_unlock_bh (&in_dev->mc_tomb_lock); + +spin_lock_bh (&im->lock);if (pmc) { -for (psf=pmc->tomb; psf; psf=psf_next) { - psf_next = psf->sf_next; -kfree (psf); + im->interface = pmc->interface; + im->crcount = in_dev->mr_qrv ?: IGMP_Unsolicited_Report_Count; + im->sfmode = pmc->sfmode; +if (pmc->sfmode ==MCAST_INCLUDE ) { + im->tomb = pmc->tomb; + im->sources = pmc->sources; +for (psf = im->sources; psf; psf = psf->sf_next) + psf->sf_crcount = im->crcount; }in_dev_put (pmc->interface); -kfree (pmc); } +spin_unlock_bh (&im->lock); } +/* +* flush ip_mc_list deleted records +*/ static void igmpv3_clear_delrec (struct in_device *in_dev) {struct ip_mc_list *pmc, *nextpmc;
@@ -1255,7 +1269,7 @@ void ip_mc_inc_group(struct in_device *ircu_assign_pointer (in_dev->mc_list, im);#ifdef CONFIG_IP_MULTICAST -igmpv3_del_delrec (in_dev, im->multiaddr); +igmpv3_del_delrec (in_dev, im);#endif igmp_group_added (im);if (!in_dev->dead)
@@ -1345,8 +1359,12 @@ void ip_mc_remap(struct in_device *in_deASSERT_RTNL (); -for_each_pmc_rtnl (in_dev, pmc) +for_each_pmc_rtnl (in_dev, pmc) { +#ifdef CONFIG_IP_MULTICAST +igmpv3_del_delrec (in_dev, pmc); +#endif igmp_group_added (pmc); + } }/* Device going down */
@@ -1367,7 +1385,6 @@ void ip_mc_down(struct in_device *in_dev in_dev->mr_gq_running =0 ;if (del_timer (&in_dev->mr_gq_timer))__in_dev_put (in_dev); -igmpv3_clear_delrec (in_dev);#endif ip_mc_dec_group (in_dev,IGMP_ALL_HOSTS );
@@ -1402,8 +1419,12 @@ void ip_mc_up(struct in_device *in_dev)ip_mc_inc_group (in_dev,IGMP_ALL_HOSTS ); -for_each_pmc_rtnl (in_dev, pmc) +for_each_pmc_rtnl (in_dev, pmc) { +#ifdef CONFIG_IP_MULTICAST +igmpv3_del_delrec (in_dev, pmc); +#endif igmp_group_added (pmc); + } }/*
@@ -1418,13 +1439,13 @@ void ip_mc_destroy_dev(struct in_device/* Deactivate timers */ ip_mc_down (in_dev); +#ifdef CONFIG_IP_MULTICAST +igmpv3_clear_delrec (in_dev); +#endif while ((i =rtnl_dereference (in_dev->mc_list)) !=NULL ) { in_dev->mc_list = i->next_rcu; in_dev->mc_count--; - -/* We've dropped the groups in ip_mc_down already */ -ip_mc_clear_src (i);ip_ma_put (i); } }
PATCH 194/199 mld: do not remove mld souce list info when set link down
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
commit 1666d49e1d416fcc2cce708242a52fe3317ea8ba upstream.
This is an IPv6 version of commit 24803f38a5c0 ("igmp: do not remove igmp souce list..."). In mld_del_delrec(), we will restore back all source filter info instead of flush them.
Move mld_clear_delrec() from ipv6_mc_down() to ipv6_mc_destroy_dev() since we should not remove source list info when set link down. Remove igmp6_group_dropped() in ipv6_mc_destroy_dev() since we have called it in ipv6_mc_down().
Also clear all source info after igmp6_group_dropped() instead of in it because ipv6_mc_down() will call igmp6_group_dropped().
[bwh: Backported to 3.2:
- Timer code moved around in ipv6_mc_down() is different
- Adjust context]
--- net/ipv6/mcast.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-)
net/ipv6/mcast.c +30 -21
@@ -92,7 +92,7 @@ static void mld_gq_timer_expire(unsignedstatic void mld_ifc_timer_expire (unsigned long data);static void mld_ifc_event (struct inet6_dev *idev);static void mld_add_delrec (struct inet6_dev *idev,struct ifmcaddr6 *pmc); -static void mld_del_delrec (struct inet6_dev *idev,const struct in6_addr *addr); +static void mld_del_delrec (struct inet6_dev *idev,struct ifmcaddr6 *pmc);static void mld_clear_delrec (struct inet6_dev *idev);static int sf_setstate (struct ifmcaddr6 *pmc);static void sf_markstate (struct ifmcaddr6 *pmc);
@@ -691,9 +691,9 @@ static void igmp6_group_dropped(struct idev_mc_del (dev, buf); } -if (mc->mca_flags &MAF_NOREPORT ) - goto done;spin_unlock_bh (&mc->mca_lock); +if (mc->mca_flags &MAF_NOREPORT ) +return ;if (!mc->idev->dead)igmp6_leave_group (mc);
@@ -701,8 +701,6 @@ static void igmp6_group_dropped(struct ispin_lock_bh (&mc->mca_lock);if (del_timer (&mc->mca_timer))atomic_dec (&mc->mca_refcnt); -done: -ip6_mc_clear_src (mc);spin_unlock_bh (&mc->mca_lock); }
@@ -747,10 +745,11 @@ static void mld_add_delrec(struct inet6_spin_unlock_bh (&idev->mc_lock); } -static void mld_del_delrec (struct inet6_dev *idev,const struct in6_addr *pmca) +static void mld_del_delrec (struct inet6_dev *idev,struct ifmcaddr6 *im) {struct ifmcaddr6 *pmc, *pmc_prev; -struct ip6_sf_list *psf, *psf_next; +struct ip6_sf_list *psf; +struct in6_addr *pmca = &im->mca_addr;spin_lock_bh (&idev->mc_lock); pmc_prev =NULL ;
@@ -767,14 +766,20 @@ static void mld_del_delrec(struct inet6_ }spin_unlock_bh (&idev->mc_lock); +spin_lock_bh (&im->mca_lock);if (pmc) { -for (psf=pmc->mca_tomb; psf; psf=psf_next) { - psf_next = psf->sf_next; -kfree (psf); + im->idev = pmc->idev; + im->mca_crcount = idev->mc_qrv; + im->mca_sfmode = pmc->mca_sfmode; +if (pmc->mca_sfmode ==MCAST_INCLUDE ) { + im->mca_tomb = pmc->mca_tomb; + im->mca_sources = pmc->mca_sources; +for (psf = im->mca_sources; psf; psf = psf->sf_next) + psf->sf_crcount = im->mca_crcount; }in6_dev_put (pmc->idev); -kfree (pmc); } +spin_unlock_bh (&im->mca_lock); }static void mld_clear_delrec (struct inet6_dev *idev)
@@ -877,7 +882,7 @@ int ipv6_dev_mc_inc(struct net_device *d idev->mc_list = mc;write_unlock_bh (&idev->lock); -mld_del_delrec (idev, &mc->mca_addr); +mld_del_delrec (idev, mc);igmp6_group_added (mc);ma_put (mc);return 0 ;
@@ -898,6 +903,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *write_unlock_bh (&idev->lock);igmp6_group_dropped (ma); +ip6_mc_clear_src (ma);ma_put (ma);return 0 ;
@@ -2231,18 +2237,20 @@ void ipv6_mc_down(struct inet6_dev *idev/* Withdraw multicast list */ read_lock_bh (&idev->lock); + +for (i = idev->mc_list; i; i=i->next) +igmp6_group_dropped (i); + +/* Should stop timer after group drop. or we will +* start timer again in mld_ifc_event() +*/ idev->mc_ifc_count =0 ;if (del_timer (&idev->mc_ifc_timer))__in6_dev_put (idev); idev->mc_gq_running =0 ;if (del_timer (&idev->mc_gq_timer))__in6_dev_put (idev); - -for (i = idev->mc_list; i; i=i->next) -igmp6_group_dropped (i);read_unlock_bh (&idev->lock); - -mld_clear_delrec (idev); }
@@ -2255,8 +2263,10 @@ void ipv6_mc_up(struct inet6_dev *idev)/* Install multicast list, except for all-nodes (already installed) */ read_lock_bh (&idev->lock); -for (i = idev->mc_list; i; i=i->next) +for (i = idev->mc_list; i; i = i->next) { +mld_del_delrec (idev, i);igmp6_group_added (i); + }read_unlock_bh (&idev->lock); }
@@ -2289,6 +2299,7 @@ void ipv6_mc_destroy_dev(struct inet6_de/* Deactivate timers */ ipv6_mc_down (idev); +mld_clear_delrec (idev);/* Delete all-nodes address. */ /* We cannot call ipv6_dev_mc_dec() directly, our caller in
@@ -2303,11 +2314,9 @@ void ipv6_mc_destroy_dev(struct inet6_dewrite_lock_bh (&idev->lock);while ((i = idev->mc_list) !=NULL ) { idev->mc_list = i->next; -write_unlock_bh (&idev->lock); -igmp6_group_dropped (i); +write_unlock_bh (&idev->lock);ma_put (i); -write_lock_bh (&idev->lock); }write_unlock_bh (&idev->lock);
PATCH 195/199 igmp, mld: Fix memory leak in igmpv3/mld_del_delrec()
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
commit 9c8bb163ae784be4f79ae504e78c862806087c54 upstream.
In function igmpv3/mld_add_delrec() we allocate pmc and put it in idev->mc_tomb, so we should free it when we don't need it in del_delrec(). But I removed kfree(pmc) incorrectly in latest two patches. Now fix it.
--- net/ipv4/igmp.c | 1 + net/ipv6/mcast.c | 1 + 2 files changed, 2 insertions(+)
net/ipv4/igmp.c +1 -0
@@ -1118,6 +1118,7 @@ static void igmpv3_del_delrec(struct in_ psf->sf_crcount = im->crcount; }in_dev_put (pmc->interface); +kfree (pmc); }spin_unlock_bh (&im->lock); }
net/ipv6/mcast.c +1 -0
@@ -778,6 +778,7 @@ static void mld_del_delrec(struct inet6_ psf->sf_crcount = im->mca_crcount; }in6_dev_put (pmc->idev); +kfree (pmc); }spin_unlock_bh (&im->mca_lock); }
PATCH 196/199 Revert "KVM: x86: expose MSR_TSC_AUX to userspace"
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
This reverts commit bc48f6f5a8c6d628a1af649306eaf906493bb986, which was commit 9dbe6cf941a6fe82933aef565e4095fb10f65023 upstream. It depends on several other large commits to work, and without them causes a regression.
References: https://bugzilla.redhat.com/show_bug.cgi?id=1408333
---
arch/x86/kvm/x86.c +1 -16
@@ -843,8 +843,7 @@ static u32 msrs_to_save[] = {#ifdef CONFIG_X86_64 MSR_CSTAR ,MSR_KERNEL_GS_BASE ,MSR_SYSCALL_MASK ,MSR_LSTAR , #endif -MSR_IA32_TSC ,MSR_IA32_CR_PAT ,MSR_VM_HSAVE_PA , - MSR_TSC_AUX, +MSR_IA32_TSC ,MSR_IA32_CR_PAT ,MSR_VM_HSAVE_PA };static unsigned num_msrs_to_save;
@@ -3882,20 +3881,6 @@ static void kvm_init_msr_list(void)for (i = j =KVM_SAVE_MSRS_BEGIN ; i <ARRAY_SIZE (msrs_to_save); i++) {if (rdmsr_safe (msrs_to_save[i], &dummy[0 ], &dummy[1 ]) <0 )continue ; - -/* -* Even MSRs that are valid in the host may not be exposed -* to the guests in some cases. -*/ -switch (msrs_to_save[i]) { -case MSR_TSC_AUX : -if (!kvm_x86_ops->rdtscp_supported ()) -continue ; -break ; -default : -break ; - } -if (j < i) msrs_to_save[j] = msrs_to_save[i]; j++;
PATCH 197/199 ipc/shm: Fix shmat mmap nil-page protection
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 95e91b831f87ac8e1f8ed50c14d709089b4e01b8 upstream.
The issue is described here, with a nice testcase:
https://bugzilla.kernel.org/show_bug.cgi?id=192931
The problem is that shmat() calls do_mmap_pgoff() with MAP_FIXED, and the address rounded down to 0. For the regular mmap case, the protection mentioned above is that the kernel gets to generate the address -- arch_get_unmapped_area() will always check for MAP_FIXED and return that address. So by the time we do security_mmap_addr(0) things get funky for shmat().
The testcase itself shows that while a regular user crashes, root will not have a problem attaching a nil-page. There are two possible fixes to this. The first, and which this patch does, is to simply allow root to crash as well -- this is also regular mmap behavior, ie when hacking up the testcase and adding mmap(... |MAP_FIXED). While this approach is the safer option, the second alternative is to ignore SHM_RND if the rounded address is 0, thus only having MAP_SHARED flags. This makes the behavior of shmat() identical to the mmap() case. The downside of this is obviously user visible, but does make sense in that it maintains semantics after the round-down wrt 0 address and mmap.
Passes shm related ltp tests.
---
ipc/shm.c +7 -2
@@ -963,8 +963,13 @@ long do_shmat(int shmid, char __user *sh goto out; else if ((addr = (ulong)shmaddr)) {if (addr & (SHMLBA -1 )) { -if (shmflg &SHM_RND ) - addr &= ~(SHMLBA -1 );/* round down */ +/* +* Round down to the nearest multiple of shmlba. +* For sane do_mmap_pgoff() parameters, avoid +* round downs that trigger nil-page and MAP_FIXED. +*/ +if ((shmflg &SHM_RND ) && addr >=SHMLBA ) + addr &= ~(SHMLBA -1 ); else#ifndef __ARCH_FORCE_SHMLBAif (addr & ~PAGE_MASK )
PATCH 198/199 sctp: avoid BUG_ON on sctp_wait_for_sndbuf
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Ricardo Leitner <[email protected]>
commit 2dcab598484185dea7ec22219c76dcdd59e3cb90 upstream.
Alexander Popov reported that an application may trigger a BUG_ON in sctp_wait_for_sndbuf if the socket tx buffer is full, a thread is waiting on it to queue more data and meanwhile another thread peels off the association being used by the first thread.
This patch replaces the BUG_ON call with a proper error handling. It will return -EPIPE to the original sendmsg call, similarly to what would have been done if the association wasn't found in the first place.
--- net/sctp/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/socket.c +2 -1
@@ -6492,7 +6492,8 @@ static int sctp_wait_for_sndbuf(struct s*/ sctp_release_sock (sk); current_timeo =schedule_timeout (current_timeo); -BUG_ON (sk != asoc->base.sk); +if (sk != asoc->base.sk) + goto do_error;sctp_lock_sock (sk); *timeo_p = current_timeo;
PATCH 199/199 sctp: deny peeloff operation on asocs with threads sleeping on it
In reply to Ben Hutchings3.2.87-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Ricardo Leitner <[email protected]>
commit dfcb9f4f99f1e9a49e43398a7bfbf56927544af1 upstream.
commit 2dcab5984841 ("sctp: avoid BUG_ON on sctp_wait_for_sndbuf") attempted to avoid a BUG_ON call when the association being used for a sendmsg() is blocked waiting for more sndbuf and another thread did a peeloff operation on such asoc, moving it to another socket.
As Ben Hutchings noticed, then in such case it would return without locking back the socket and would cause two unlocks in a row.
Further analysis also revealed that it could allow a double free if the application managed to peeloff the asoc that is created during the sendmsg call, because then sctp_sendmsg() would try to free the asoc that was created only for that call.
This patch takes another approach. It will deny the peeloff operation if there is a thread sleeping on the asoc, so this situation doesn't exist anymore. This avoids the issues described above and also honors the syscalls that are already being handled (it can be multiple sendmsg calls).
Joint work with Xin Long.
--- net/sctp/socket.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/sctp/socket.c +6 -2
@@ -4242,6 +4242,12 @@ SCTP_STATIC int sctp_do_peeloff(struct sstruct sctp_af *af;int err =0 ; +/* If there is a thread waiting on more sndbuf space for +* sending on this asoc, it cannot be peeled. +*/ +if (waitqueue_active (&asoc->wait)) +return -EBUSY ; +/* An association cannot be branched off from an already peeled-off * socket, nor is this supported for tcp style sockets. */
@@ -6492,8 +6498,6 @@ static int sctp_wait_for_sndbuf(struct s*/ sctp_release_sock (sk); current_timeo =schedule_timeout (current_timeo); -if (sk != asoc->base.sk) - goto do_error;sctp_lock_sock (sk); *timeo_p = current_timeo;
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.2.87 release. There are 199 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Mar 15 00:00:00 UTC 2017. Anything received after that time might be too late.
Build results:
total: 89 pass: 89 fail: 0 Qemu test results: total: 69 pass: 69 fail: 0
Details are available at http://kerneltests.org/builders/
Guenter
Quoted 13 lines · Guenter Roeck
Quoted 11 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.2.87 release.
There are 199 patches in this series, which will be posted as responses
to this one. If anyone has any issues with these being applied, please
let me know.Responses should be made by Wed Mar 15 00:00:00 UTC 2017. Anything received after that time might be too late.
Quoted 6 lines
Build results:
total: 89 pass: 89 fail: 0 Qemu test results: total: 69 pass: 69 fail: 0Details are available at http://kerneltests.org/builders/
Thanks for checking.
Ben.
Signature · 2 lines
Ben Hutchings If you seem to know what you are doing, you'll be given more to do.
cover 3.2.87-rc2 review
In reply to Ben HutchingsI've added three more patches to the queue for this release, which will be sent as replies to this message.
Responses should be made by Wed Mar 15 00:00:00 UTC 2017. Anything received after that time might be too late.
Ben.
Signature · 2 lines
Ben Hutchings If you seem to know what you are doing, you'll be given more to do.
PATCH 200/202 TTY: n_hdlc, fix lockdep false positive
3.2.87-rc2 review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby <[email protected]>
commit e9b736d88af1a143530565929390cadf036dc799 upstream.
The class of 4 n_hdls buf locks is the same because a single function n_hdlc_buf_list_init is used to init all the locks. But sinceflush_tx_queue takes n_hdlc->tx_buf_list.spinlock and then callsn_hdlc_buf_put which takes n_hdlc->tx_free_buf_list.spinlock, lockdep
emits a warning:
=============================================
[ INFO: possible recursive locking detected ]
4.3.0-25.g91e30a7-default #1 Not tainted
---------------------------------------------
a.out/1248 is trying to acquire lock:
(&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fd020>] n_hdlc_buf_put+0x20/0x60 [n_hdlc]
but task is already holding lock:
(&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fdc07>] n_hdlc_tty_ioctl+0x127/0x1d0 [n_hdlc]
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&(&list->spinlock)->rlock);
lock(&(&list->spinlock)->rlock);
*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by a.out/1248:
#0: (&tty->ldisc_sem){++++++}, at: [<ffffffff814c9eb0>] tty_ldisc_ref_wait+0x20/0x50 #1: (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fdc07>] n_hdlc_tty_ioctl+0x127/0x1d0 [n_hdlc]
...
Call Trace: ... [<ffffffff81738fd0>] _raw_spin_lock_irqsave+0x50/0x70 [<ffffffffa01fd020>] n_hdlc_buf_put+0x20/0x60 [n_hdlc] [<ffffffffa01fdc24>] n_hdlc_tty_ioctl+0x144/0x1d0 [n_hdlc] [<ffffffff814c25c1>] tty_ioctl+0x3f1/0xe40
...
Fix it by initializing the spin_locks separately. This removes also reduntand memset of a freshly kzallocated space.
--- drivers/tty/n_hdlc.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/tty/n_hdlc.c +4 -15
@@ -160,7 +160,6 @@ struct n_hdlc {/* * HDLC buffer list manipulation functions */ -static void n_hdlc_buf_list_init (struct n_hdlc_buf_list *list);static void n_hdlc_buf_put (struct n_hdlc_buf_list *list,struct n_hdlc_buf *buf);static struct n_hdlc_buf *n_hdlc_buf_get (struct n_hdlc_buf_list *list);
@@ -856,10 +855,10 @@ static struct n_hdlc *n_hdlc_alloc(void)memset (n_hdlc,0 ,sizeof (*n_hdlc)); -n_hdlc_buf_list_init (&n_hdlc->rx_free_buf_list); -n_hdlc_buf_list_init (&n_hdlc->tx_free_buf_list); -n_hdlc_buf_list_init (&n_hdlc->rx_buf_list); -n_hdlc_buf_list_init (&n_hdlc->tx_buf_list); +spin_lock_init (&n_hdlc->rx_free_buf_list.spinlock); +spin_lock_init (&n_hdlc->tx_free_buf_list.spinlock); +spin_lock_init (&n_hdlc->rx_buf_list.spinlock); +spin_lock_init (&n_hdlc->tx_buf_list.spinlock);/* allocate free rx buffer list */ for (i=0 ;i<DEFAULT_RX_BUF_COUNT ;i++) {
@@ -888,16 +887,6 @@ static struct n_hdlc *n_hdlc_alloc(void) }/* end of n_hdlc_alloc() */ /** -* n_hdlc_buf_list_init - initialize specified HDLC buffer list -* @list - pointer to buffer list -*/ -static void n_hdlc_buf_list_init (struct n_hdlc_buf_list *list) -{ -memset (list,0 ,sizeof (*list)); -spin_lock_init (&list->spinlock); -}/* end of n_hdlc_buf_list_init() */ - -/** * n_hdlc_buf_put - add specified HDLC buffer to tail of specified list * @list - pointer to buffer list * @buf - pointer to buffer
PATCH 201/202 list: introduce list_first_entry_or_null
In reply to Ben Hutchings3.2.87-rc2 review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Pirko <[email protected]>
commit 6d7581e62f8be462440d7b22c6361f7c9fa4902b upstream.
non-rcu variant of list_first_or_null_rcu
--- include/linux/list.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/list.h +11 -0
@@ -362,6 +362,17 @@ static inline void list_splice_tail_init(struct list_head *list,list_entry ((ptr)->next, type, member)/** +* list_first_entry_or_null - get the first element from a list +* @ptr: the list head to take the element from. +* @type: the type of the struct this is embedded in. +* @member: the name of the list_struct within the struct. +* +* Note that if the list is empty, it returns NULL. + */ +#define list_first_entry_or_null (ptr, type, member) \ + (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) + +/** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list.
PATCH 202/202 tty: n_hdlc: get rid of racy n_hdlc.tbuf
In reply to Ben Hutchings3.2.87-rc2 review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Popov <[email protected]>
commit 82f2341c94d270421f383641b7cd670e474db56b upstream.
Currently N_HDLC line discipline uses a self-made singly linked list for data buffers and has n_hdlc.tbuf pointer for buffer retransmitting after an error.
The commit be10eb7589337e5defbe214dae038a53dd21add8
("tty: n_hdlc add buffer flushing") introduced racy access to n_hdlc.tbuf. After tx error concurrent flush_tx_queue() and n_hdlc_send_frames() can put one data buffer to tx_free_buf_list twice. That causes double free in n_hdlc_release().
Let's use standard kernel linked list and get rid of n_hdlc.tbuf:
in case of tx error put current data buffer after the head of tx_buf_list.
--- drivers/tty/n_hdlc.c | 132 +++++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 63 deletions(-)
drivers/tty/n_hdlc.c +69 -63
@@ -115,7 +115,7 @@#define DEFAULT_TX_BUF_COUNT 3struct n_hdlc_buf { -struct n_hdlc_buf *link; +struct list_head list_item;int count;char buf[1 ]; };
@@ -123,8 +123,7 @@ struct n_hdlc_buf {#define N_HDLC_BUF_SIZE (sizeof(struct n_hdlc_buf) + maxframe)struct n_hdlc_buf_list { -struct n_hdlc_buf *head; -struct n_hdlc_buf *tail; +struct list_head list;int count;spinlock_t spinlock; };
@@ -137,7 +136,6 @@ struct n_hdlc_buf_list {* @backup_tty - TTY to use if tty gets closed * @tbusy - reentrancy flag for tx wakeup code * @woke_up - FIXME: describe this field -* @tbuf - currently transmitting tx buffer * @tx_buf_list - list of pending transmit frame buffers * @rx_buf_list - list of received frame buffers * @tx_free_buf_list - list unused transmit frame buffers
@@ -150,7 +148,6 @@ struct n_hdlc {struct tty_struct *backup_tty;int tbusy;int woke_up; -struct n_hdlc_buf *tbuf;struct n_hdlc_buf_list tx_buf_list;struct n_hdlc_buf_list rx_buf_list;struct n_hdlc_buf_list tx_free_buf_list;
@@ -160,6 +157,8 @@ struct n_hdlc {/* * HDLC buffer list manipulation functions */ +static void n_hdlc_buf_return (struct n_hdlc_buf_list *buf_list, +struct n_hdlc_buf *buf);static void n_hdlc_buf_put (struct n_hdlc_buf_list *list,struct n_hdlc_buf *buf);static struct n_hdlc_buf *n_hdlc_buf_get (struct n_hdlc_buf_list *list);
@@ -209,16 +208,9 @@ static void flush_tx_queue(struct tty_st {struct n_hdlc *n_hdlc =tty2n_hdlc (tty);struct n_hdlc_buf *buf; -unsigned long flags;while ((buf =n_hdlc_buf_get (&n_hdlc->tx_buf_list)))n_hdlc_buf_put (&n_hdlc->tx_free_buf_list, buf); -spin_lock_irqsave (&n_hdlc->tx_buf_list.spinlock, flags); -if (n_hdlc->tbuf) { -n_hdlc_buf_put (&n_hdlc->tx_free_buf_list, n_hdlc->tbuf); - n_hdlc->tbuf =NULL ; - } -spin_unlock_irqrestore (&n_hdlc->tx_buf_list.spinlock, flags); }static struct tty_ldisc_ops n_hdlc_ldisc = {
@@ -284,7 +276,6 @@ static void n_hdlc_release(struct n_hdlc }else break ; } -kfree (n_hdlc->tbuf);kfree (n_hdlc); }/* end of n_hdlc_release() */
@@ -403,13 +394,7 @@ static void n_hdlc_send_frames(struct n_ n_hdlc->woke_up =0 ;spin_unlock_irqrestore (&n_hdlc->tx_buf_list.spinlock, flags); -/* get current transmit buffer or get new transmit */ -/* buffer from list of pending transmit buffers */ - - tbuf = n_hdlc->tbuf; -if (!tbuf) - tbuf =n_hdlc_buf_get (&n_hdlc->tx_buf_list); - + tbuf =n_hdlc_buf_get (&n_hdlc->tx_buf_list);while (tbuf) {if (debuglevel >=DEBUG_LEVEL_INFO ) printk("%s(%d)sending frame %p, count=%d\n",
@@ -421,7 +406,7 @@ static void n_hdlc_send_frames(struct n_/* rollback was possible and has been done */ if (actual == -ERESTARTSYS ) { - n_hdlc->tbuf = tbuf; +n_hdlc_buf_return (&n_hdlc->tx_buf_list, tbuf);break ; }/* if transmit error, throw frame away by */
@@ -436,10 +421,7 @@ static void n_hdlc_send_frames(struct n_/* free current transmit buffer */ n_hdlc_buf_put (&n_hdlc->tx_free_buf_list, tbuf); - -/* this tx buffer is done */ - n_hdlc->tbuf =NULL ; - +/* wait up sleeping writers */ wake_up_interruptible (&tty->write_wait);
@@ -449,10 +431,12 @@ static void n_hdlc_send_frames(struct n_if (debuglevel >=DEBUG_LEVEL_INFO )printk ("%s(%d)frame %p pending\n" , __FILE__,__LINE__,tbuf); - -/* buffer not accepted by driver */ -/* set this buffer as pending buffer */ - n_hdlc->tbuf = tbuf; + +/* +* the buffer was not accepted by driver, +* return it back into tx queue +*/ +n_hdlc_buf_return (&n_hdlc->tx_buf_list, tbuf);break ; } }
@@ -750,7 +734,8 @@ static int n_hdlc_tty_ioctl(struct tty_sint error =0 ;int count;unsigned long flags; - +struct n_hdlc_buf *buf =NULL ; +if (debuglevel >=DEBUG_LEVEL_INFO )printk ("%s(%d)n_hdlc_tty_ioctl() called %d\n" , __FILE__,__LINE__,cmd);
@@ -764,8 +749,10 @@ static int n_hdlc_tty_ioctl(struct tty_s/* report count of read data available */ /* in next available frame (if any) */ spin_lock_irqsave (&n_hdlc->rx_buf_list.spinlock,flags); -if (n_hdlc->rx_buf_list.head) - count = n_hdlc->rx_buf_list.head->count; + buf =list_first_entry_or_null (&n_hdlc->rx_buf_list.list, + struct n_hdlc_buf, list_item); +if (buf) + count = buf->count;else count =0 ;spin_unlock_irqrestore (&n_hdlc->rx_buf_list.spinlock,flags);
@@ -777,8 +764,10 @@ static int n_hdlc_tty_ioctl(struct tty_s count =tty_chars_in_buffer (tty);/* add size of next output frame in queue */ spin_lock_irqsave (&n_hdlc->tx_buf_list.spinlock,flags); -if (n_hdlc->tx_buf_list.head) - count += n_hdlc->tx_buf_list.head->count; + buf =list_first_entry_or_null (&n_hdlc->tx_buf_list.list, + struct n_hdlc_buf, list_item); +if (buf) + count += buf->count;spin_unlock_irqrestore (&n_hdlc->tx_buf_list.spinlock,flags); error =put_user (count, (int __user *)arg);break ;
@@ -826,14 +815,14 @@ static unsigned int n_hdlc_tty_poll(strupoll_wait (filp, &tty->write_wait, wait);/* set bits for operations that won't block */ -if (n_hdlc->rx_buf_list.head) +if (!list_empty (&n_hdlc->rx_buf_list.list)) mask |=POLLIN |POLLRDNORM ;/* readable */ if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) mask |=POLLHUP ;if (tty_hung_up_p (filp)) mask |=POLLHUP ;if (!tty_is_writelocked (tty) && - n_hdlc->tx_free_buf_list.head) + !list_empty (&n_hdlc->tx_free_buf_list.list)) mask |=POLLOUT |POLLWRNORM ;/* writable */ }return mask;
@@ -859,7 +848,12 @@ static struct n_hdlc *n_hdlc_alloc(void)spin_lock_init (&n_hdlc->tx_free_buf_list.spinlock);spin_lock_init (&n_hdlc->rx_buf_list.spinlock);spin_lock_init (&n_hdlc->tx_buf_list.spinlock); - + +INIT_LIST_HEAD (&n_hdlc->rx_free_buf_list.list); +INIT_LIST_HEAD (&n_hdlc->tx_free_buf_list.list); +INIT_LIST_HEAD (&n_hdlc->rx_buf_list.list); +INIT_LIST_HEAD (&n_hdlc->tx_buf_list.list); +/* allocate free rx buffer list */ for (i=0 ;i<DEFAULT_RX_BUF_COUNT ;i++) { buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_KERNEL );
@@ -887,53 +881,65 @@ static struct n_hdlc *n_hdlc_alloc(void) }/* end of n_hdlc_alloc() */ /** +* n_hdlc_buf_return - put the HDLC buffer after the head of the specified list +* @buf_list - pointer to the buffer list +* @buf - pointer to the buffer +*/ +static void n_hdlc_buf_return (struct n_hdlc_buf_list *buf_list, +struct n_hdlc_buf *buf) +{ +unsigned long flags; + +spin_lock_irqsave (&buf_list->spinlock, flags); + +list_add (&buf->list_item, &buf_list->list); + buf_list->count++; + +spin_unlock_irqrestore (&buf_list->spinlock, flags); +} + +/** * n_hdlc_buf_put - add specified HDLC buffer to tail of specified list -* @list - pointer to buffer list +* @buf_list - pointer to buffer list * @buf - pointer to buffer */ -static void n_hdlc_buf_put (struct n_hdlc_buf_list *list, +static void n_hdlc_buf_put (struct n_hdlc_buf_list *buf_list,struct n_hdlc_buf *buf) {unsigned long flags; -spin_lock_irqsave (&list->spinlock,flags); - - buf->link=NULL ; -if (list->tail) - list->tail->link = buf; -else - list->head = buf; - list->tail = buf; - (list->count)++; - -spin_unlock_irqrestore (&list->spinlock,flags); - + +spin_lock_irqsave (&buf_list->spinlock, flags); + +list_add_tail (&buf->list_item, &buf_list->list); + buf_list->count++; + +spin_unlock_irqrestore (&buf_list->spinlock, flags); }/* end of n_hdlc_buf_put() */ /** * n_hdlc_buf_get - remove and return an HDLC buffer from list -* @list - pointer to HDLC buffer list +* @buf_list - pointer to HDLC buffer list * * Remove and return an HDLC buffer from the head of the specified HDLC buffer * list. * Returns a pointer to HDLC buffer if available, otherwise %NULL. */ -static struct n_hdlc_buf *n_hdlc_buf_get (struct n_hdlc_buf_list *list) +static struct n_hdlc_buf *n_hdlc_buf_get (struct n_hdlc_buf_list *buf_list) {unsigned long flags;struct n_hdlc_buf *buf; -spin_lock_irqsave (&list->spinlock,flags); - - buf = list->head; + +spin_lock_irqsave (&buf_list->spinlock, flags); + + buf =list_first_entry_or_null (&buf_list->list, + struct n_hdlc_buf, list_item);if (buf) { - list->head = buf->link; - (list->count)--; +list_del (&buf->list_item); + buf_list->count--; } -if (!list->head) - list->tail =NULL ; - -spin_unlock_irqrestore (&list->spinlock,flags); + +spin_unlock_irqrestore (&buf_list->spinlock, flags);return buf; - }/* end of n_hdlc_buf_get() */ static char hdlc_banner[] __initdata =
Re: [PATCH 3.2 000/202] 3.2.87-rc2 review
In reply to Ben HutchingsThis is the combined diff for 3.2.87-rc2 relative to 3.2.86.
Ben.
Signature · 2 lines
Ben Hutchings If you seem to know what you are doing, you'll be given more to do.
Makefile +2 -2
@@ -1,7 +1,7 @@ VERSION = 3 PATCHLEVEL = 2 -SUBLEVEL = 86 -EXTRAVERSION = +SUBLEVEL = 87 +EXTRAVERSION = -rc2 NAME = Saber-toothed Squirrel # *DOCUMENTATION*
arch/arm/include/asm/cputype.h +3 -0
@@ -25,6 +25,9 @@#define CPUID_EXT_ISAR4 "c2, 4"#define CPUID_EXT_ISAR5 "c2, 5" +/* Qualcomm implemented cores */ +#define ARM_CPU_PART_SCORPION 0x510002d0 +extern unsigned int processor_id;#ifdef CONFIG_CPU_CP15
arch/arm/kernel/hw_breakpoint.c +16 -0
@@ -1001,6 +1001,22 @@ static int __init arch_hw_breakpoint_init(void)return 0 ; } +/* +* Scorpion CPUs (at least those in APQ8060) seem to set DBGPRSR.SPD +* whenever a WFI is issued, even if the core is not powered down, in +* violation of the architecture. When DBGPRSR.SPD is set, accesses to +* breakpoint and watchpoint registers are treated as undefined, so +* this results in boot time and runtime failures when these are +* accessed and we unexpectedly take a trap. +* +* It's not clear if/how this can be worked around, so we blacklist +* Scorpion CPUs to avoid these issues. +*/ +if ((read_cpuid_id () &0xff00fff0 ) ==ARM_CPU_PART_SCORPION ) { +pr_info ("Scorpion CPU detected. Hardware breakpoints and watchpoints disabled\n" ); +return 0 ; + } +/* Determine how many BRPs/WRPs are available. */ core_num_brps =get_num_brps (); core_num_wrps =get_num_wrps ();
arch/arm/kernel/ptrace.c +1 -1
@@ -593,7 +593,7 @@ static int gpr_set(struct task_struct *target, const void *kbuf, const void __user *ubuf) { int ret; -struct pt_regs newregs; +struct pt_regs newregs = *task_pt_regs (target); ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newregs,
arch/cris/boot/rescue/Makefile +8 -0
@@ -10,6 +10,9 @@ asflags-y += $(LINUXINCLUDE) ccflags-y += -O2 $(LINUXINCLUDE) + +ifdef CONFIG_ETRAX_AXISFLASHMAP + arch-$(CONFIG_ETRAX_ARCH_V10) = v10 arch-$(CONFIG_ETRAX_ARCH_V32) = v32
@@ -28,6 +31,11 @@ $(obj)/rescue.bin: $(obj)/rescue.o FORCE $(call if_changed,objcopy) cp -p $(obj)/rescue.bin $(objtree) +else +$(obj)/rescue.bin: + +endif + $(obj)/testrescue.bin: $(obj)/testrescue.o $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin # Pad it to 784 bytes
arch/parisc/include/asm/bitops.h +7 -1
@@ -6,7 +6,7 @@#endif #include <linux/compiler.h> -#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */ +#include <asm/types.h> #include <asm/byteorder.h> #include <linux/atomic.h>
@@ -16,6 +16,12 @@* to include/asm-i386/bitops.h or kerneldoc */ +#if __BITS_PER_LONG ==64 +#define SHIFT_PER_LONG 6 +#else +#define SHIFT_PER_LONG 5 +#endif +#define CHOP_SHIFTCOUNT (x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
arch/parisc/include/asm/bitsperlong.h +0 -2
@@ -9,10 +9,8 @@*/ #if (defined(__KERNEL__) && defined(CONFIG_64BIT )) || defined (__LP64__)#define __BITS_PER_LONG 64 -#define SHIFT_PER_LONG 6#else #define __BITS_PER_LONG 32 -#define SHIFT_PER_LONG 5#endif #include <asm-generic/bitsperlong.h>
arch/parisc/include/asm/swab.h +3 -2
@@ -1,6 +1,7 @@#ifndef _PARISC_SWAB_H#define _PARISC_SWAB_H +#include <asm/bitsperlong.h> #include <linux/types.h> #include <linux/compiler.h>
@@ -38,7 +39,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x) }#define __arch_swab32 __arch_swab32 -#if BITS_PER_LONG >32 +#if __BITS_PER_LONG >32 /* ** From "PA-RISC 2.0 Architecture", HP Professional Books. ** See Appendix I page 8 , "Endian Byte Swapping".
@@ -61,6 +62,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x)return x; }#define __arch_swab64 __arch_swab64 -#endif /* BITS_PER_LONG > 32 */ +#endif /* __BITS_PER_LONG > 32 */ #endif /* _PARISC_SWAB_H */
arch/powerpc/boot/ps3-head.S +0 -5
@@ -57,11 +57,6 @@ __system_reset_overlay: bctr 1: - /* Save the value at addr zero for a null pointer write check later. */ - - li r4, 0 - lwz r3, 0(r4) - /* Primary delays then goes to _zimage_start in wrapper. */ or 31, 31, 31 /* db16cyc */
arch/powerpc/boot/ps3.c +1 -7
@@ -119,13 +119,12 @@ void ps3_copy_vectors(void)flush_cache ((void *)0x100 ,512 ); } -void platform_init (unsigned long null_check) +void platform_init (void ) {const u32 heapsize =0x1000000 - (u32 )_end;/* 16MiB */ void *chosen;unsigned long ft_addr;u64 rm_size; -unsigned long val; console_ops.write = ps3_console_write; platform_ops.exit = ps3_exit;
@@ -153,11 +152,6 @@ void platform_init(unsigned long null_check)printf (" flat tree at 0x%lx\n\r" , ft_addr); - val = *(unsigned long *)0 ; - -if (val != null_check) -printf ("null check failed: %lx != %lx\n\r" , val, null_check); - ((kernel_entry_t )0 )(ft_addr,0 ,NULL );ps3_exit ();
arch/powerpc/include/asm/ppc-opcode.h +3 -3
@@ -31,7 +31,7 @@#define PPC_INST_MCRXR 0x7c000400#define PPC_INST_MCRXR_MASK 0xfc0007fe#define PPC_INST_MFSPR_PVR 0x7c1f42a6 -#define PPC_INST_MFSPR_PVR_MASK 0xfc1fffff +#define PPC_INST_MFSPR_PVR_MASK 0xfc1ffffe#define PPC_INST_MSGSND 0x7c00019c#define PPC_INST_NOP 0x60000000#define PPC_INST_POPCNTB 0x7c0000f4
@@ -42,9 +42,9 @@#define PPC_INST_RFDI 0x4c00004e#define PPC_INST_RFMCI 0x4c00004c#define PPC_INST_MFSPR_DSCR 0x7c1102a6 -#define PPC_INST_MFSPR_DSCR_MASK 0xfc1fffff +#define PPC_INST_MFSPR_DSCR_MASK 0xfc1ffffe#define PPC_INST_MTSPR_DSCR 0x7c1103a6 -#define PPC_INST_MTSPR_DSCR_MASK 0xfc1fffff +#define PPC_INST_MTSPR_DSCR_MASK 0xfc1ffffe#define PPC_INST_STRING 0x7c00042a#define PPC_INST_STRING_MASK 0xfc0007fe
arch/powerpc/kernel/ibmebus.c +12 -4
@@ -179,6 +179,7 @@ static int ibmebus_create_device(struct device_node *dn)static int ibmebus_create_devices (const struct of_device_id *matches) {struct device_node *root, *child; +struct device *dev;int ret =0 ; root =of_find_node_by_path ("/" );
@@ -187,9 +188,12 @@ static int ibmebus_create_devices(const struct of_device_id *matches)if (!of_match_node (matches, child))continue ; -if (bus_find_device (&ibmebus_bus_type,NULL , child, - ibmebus_match_node)) + dev =bus_find_device (&ibmebus_bus_type,NULL , child, + ibmebus_match_node); +if (dev) { +put_device (dev);continue ; + } ret =ibmebus_create_device (child);if (ret) {
@@ -261,6 +265,7 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus, const char *buf, size_t count) {struct device_node *dn =NULL ; +struct device *dev;char *path;ssize_t rc =0 ;
@@ -268,8 +273,10 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,if (!path)return -ENOMEM ; -if (bus_find_device (&ibmebus_bus_type,NULL , path, - ibmebus_match_path)) { + dev =bus_find_device (&ibmebus_bus_type,NULL , path, + ibmebus_match_path); +if (dev) { +put_device (dev);printk (KERN_WARNING "%s: %s has already been probed\n" , __func__, path); rc = -EEXIST ;
@@ -305,6 +312,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,if ((dev =bus_find_device (&ibmebus_bus_type,NULL , path, ibmebus_match_path))) {of_device_unregister (to_platform_device (dev)); +put_device (dev);kfree (path);return count;
arch/powerpc/kernel/ptrace.c +7 -0
@@ -359,6 +359,10 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,flush_fp_to_thread (target);#ifdef CONFIG_VSX +for (i =0 ; i <32 ; i++) + buf[i] = target->thread.TS_FPR (i); +memcpy (&buf[32 ], &target->thread.fpscr,sizeof (double )); +/* copy to local buffer then write that out */ i =user_regset_copyin (&pos, &count, &kbuf, &ubuf, buf,0 ,-1 );if (i)
@@ -501,6 +505,9 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,flush_vsx_to_thread (target); +for (i =0 ; i <32 ; i++) + buf[i] = target->thread.fpr[i][TS_VSRLOWOFFSET ]; + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, buf,0 ,32 *sizeof (double ));for (i =0 ; i <32 ; i++)
arch/sparc/kernel/leon_kernel.c +28 -28
65 lines not on this page · raw message
arch/x86/kernel/cpu/common.c +1 -1
@@ -1012,7 +1012,7 @@ static __init int setup_disablecpuid(char *arg) {int bit; -if (get_option (&arg, &bit) && bit <NCAPINTS *32 ) +if (get_option (&arg, &bit) && bit >=0 && bit <NCAPINTS *32 )setup_clear_cpu_cap (bit);else return 0 ;
arch/x86/kvm/x86.c +1 -16
@@ -843,8 +843,7 @@ static u32 msrs_to_save[] = {#ifdef CONFIG_X86_64 MSR_CSTAR ,MSR_KERNEL_GS_BASE ,MSR_SYSCALL_MASK ,MSR_LSTAR , #endif -MSR_IA32_TSC ,MSR_IA32_CR_PAT ,MSR_VM_HSAVE_PA , - MSR_TSC_AUX, +MSR_IA32_TSC ,MSR_IA32_CR_PAT ,MSR_VM_HSAVE_PA };static unsigned num_msrs_to_save;
@@ -3882,20 +3881,6 @@ static void kvm_init_msr_list(void)for (i = j =KVM_SAVE_MSRS_BEGIN ; i <ARRAY_SIZE (msrs_to_save); i++) {if (rdmsr_safe (msrs_to_save[i], &dummy[0 ], &dummy[1 ]) <0 )continue ; - -/* -* Even MSRs that are valid in the host may not be exposed -* to the guests in some cases. -*/ -switch (msrs_to_save[i]) { -case MSR_TSC_AUX : -if (!kvm_x86_ops->rdtscp_supported ()) -continue ; -break ; -default : -break ; - } -if (j < i) msrs_to_save[j] = msrs_to_save[i]; j++;
crypto/algapi.c +1 -0
@@ -354,6 +354,7 @@ int crypto_register_alg(struct crypto_alg *alg)struct crypto_larval *larval;int err; + alg->cra_flags &= ~CRYPTO_ALG_DEAD ; err =crypto_check_alg (alg);if (err)return err;
drivers/ata/sata_mv.c +3 -0
@@ -4059,6 +4059,9 @@ static int mv_platform_probe(struct platform_device *pdev) host->iomap =NULL ; hpriv->base =devm_ioremap (&pdev->dev, res->start,resource_size (res)); +if (!hpriv->base) +return -ENOMEM ; + hpriv->base -=SATAHC0_REG_BASE ;#if defined(CONFIG_HAVE_CLK )
drivers/base/dma-mapping.c +2 -2
@@ -106,13 +106,13 @@ void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,EXPORT_SYMBOL (dmam_free_coherent);/** -* dmam_alloc_non_coherent - Managed dma_alloc_non_coherent() +* dmam_alloc_non_coherent - Managed dma_alloc_noncoherent() * @dev: Device to allocate non_coherent memory for * @size: Size of allocation * @dma_handle: Out argument for allocated DMA handle * @gfp: Allocation flags * -* Managed dma_alloc_non_coherent(). Memory allocated using this +* Managed dma_alloc_noncoherent(). Memory allocated using this * function will be automatically released on driver detach. * * RETURNS:
drivers/base/regmap/regcache-lzo.c +2 -6
@@ -229,15 +229,13 @@ static int regcache_lzo_read(struct regmap *map, {struct regcache_lzo_ctx *lzo_block, **lzo_blocks;int ret, blkindex, blkpos; -size_t blksize, tmp_dst_len; +size_t tmp_dst_len;void *tmp_dst;/* index of the compressed lzo block */ blkindex =regcache_lzo_get_blkindex (map, reg);/* register index within the decompressed block */ blkpos =regcache_lzo_get_blkpos (map, reg); -/* size of the compressed block */ - blksize =regcache_lzo_get_blksize (map); lzo_blocks = map->cache; lzo_block = lzo_blocks[blkindex];
@@ -269,15 +267,13 @@ static int regcache_lzo_write(struct regmap *map, {struct regcache_lzo_ctx *lzo_block, **lzo_blocks;int ret, blkindex, blkpos; -size_t blksize, tmp_dst_len; +size_t tmp_dst_len;void *tmp_dst;/* index of the compressed lzo block */ blkindex =regcache_lzo_get_blkindex (map, reg);/* register index within the decompressed block */ blkpos =regcache_lzo_get_blkpos (map, reg); -/* size of the compressed block */ - blksize =regcache_lzo_get_blksize (map); lzo_blocks = map->cache; lzo_block = lzo_blocks[blkindex];
drivers/block/nbd.c +23 -11
@@ -232,9 +232,10 @@ static inline int sock_send_bvec(struct nbd_device *lo, struct bio_vec *bvec,/* always call with the tx_lock held */ static int nbd_send_req (struct nbd_device *lo,struct request *req) { -int result, flags; +int result;struct nbd_request request;unsigned long size =blk_rq_bytes (req); +struct bio *bio; request.magic =htonl (NBD_REQUEST_MAGIC ); request.type =htonl (nbd_cmd (req));
@@ -255,17 +256,19 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) goto error_out; } -if (nbd_cmd (req) ==NBD_CMD_WRITE ) { -struct req_iterator iter; +if (nbd_cmd (req) !=NBD_CMD_WRITE ) +return 0 ; + + bio = req->bio; +while (bio) { +struct bio *next = bio->bi_next; +int i;struct bio_vec *bvec; -/* -* we are really probing at internals to determine -* whether to set MSG_MORE or not... -*/ -rq_for_each_segment (bvec, req, iter) { - flags =0 ; -if (!rq_iter_last (req, iter)) - flags =MSG_MORE ; + +bio_for_each_segment (bvec, bio, i) { +bool is_last = !next && i == bio->bi_vcnt -1 ; +int flags = is_last ?0 :MSG_MORE ; +dprintk (DBG_TX ,"%s: request %p: sending %d bytes data\n" , lo->disk->disk_name, req, bvec->bv_len); result =sock_send_bvec (lo, bvec, flags);
@@ -275,7 +278,16 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) result); goto error_out; } +/* +* The completion might already have come in, +* so break for the last one instead of letting +* the iterator do it. This prevents use-after-free +* of the bio. +*/ +if (is_last) +break ; } + bio = next; }return 0 ;
drivers/crypto/caam/caamalg.c +3 -1
@@ -419,7 +419,9 @@ static int aead_set_sh_desc(struct crypto_aead *aead)/* Will read cryptlen */ append_math_add (desc,VARSEQINLEN ,SEQINLEN ,REG0 ,CAAM_CMD_SZ ); -aead_append_src_dst (desc,FIFOLD_TYPE_MSG1OUT2 ); +append_seq_fifo_load (desc,0 ,FIFOLD_CLASS_BOTH |KEY_VLF | +FIFOLD_TYPE_MSG1OUT2 |FIFOLD_TYPE_LASTBOTH ); +append_seq_fifo_store (desc,0 ,FIFOST_TYPE_MESSAGE_DATA |KEY_VLF );/* Write ICV */ append_seq_store(desc, ctx->authsize, LDST_CLASS_2_CCB |
drivers/hid/hid-cypress.c +3 -0
@@ -40,6 +40,9 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,if (!(quirks &CP_RDESC_SWAPPED_MIN_MAX ))return rdesc; +if (*rsize <4 ) +return rdesc; +for (i =0 ; i < *rsize -4 ; i++)if (rdesc[i] ==0x29 && rdesc[i +2 ] ==0x19 ) {__u8 tmp;
drivers/hwmon/ds620.c +1 -1
@@ -166,7 +166,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,if (res)return res; - val = (val *10 /625 ) *8 ; + val = (clamp_val (val,-128000 ,128000 ) *10 /625 ) *8 ;mutex_lock (&data->update_lock); data->temp[attr->index] = val;
drivers/i2c/i2c-dev.c +1 -1
@@ -310,7 +310,7 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client, unsigned long arg) {struct i2c_smbus_ioctl_data data_arg; -union i2c_smbus_data temp; +union i2c_smbus_data temp = {};int datasize, res; if (copy_from_user(&data_arg,
drivers/infiniband/core/mad.c +1 -1
@@ -1598,7 +1598,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,if (!class) goto out;if (convert_mgmt_class (mad->mad_hdr.mgmt_class) >= -IB_MGMT_MAX_METHODS ) +ARRAY_SIZE (class->method_table)) goto out; method = class->method_table[convert_mgmt_class ( mad->mad_hdr.mgmt_class)];
drivers/infiniband/core/multicast.c +5 -2
@@ -516,8 +516,11 @@ static void join_handler(int status, struct ib_sa_mcmember_rec *rec,if (status)process_join_error (group, status);else { -ib_find_pkey (group->port->dev->device, group->port->port_num, -be16_to_cpu (rec->pkey), &pkey_index); + +if (ib_find_pkey (group->port->dev->device, + group->port->port_num,be16_to_cpu (rec->pkey), + &pkey_index)) + pkey_index =MCAST_INVALID_PKEY_INDEX ;spin_lock_irq (&group->port->lock); group->rec = *rec;
drivers/infiniband/hw/mlx4/main.c +1 -0
@@ -164,6 +164,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * props->max_mcast_grp; props->max_map_per_fmr = (1 << (32 -ilog2 (dev->dev->caps.num_mpts))) -1 ; + props->max_ah =INT_MAX ; out:kfree (in_mad);
drivers/input/serio/i8042-x86ia64io.h +6 -0
@@ -211,6 +211,12 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = { DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "PEGATRON CORPORATION"), + DMI_MATCH(DMI_PRODUCT_NAME, "C15B"), + }, + }, { } };
drivers/iommu/amd_iommu.c +1 -1
@@ -641,7 +641,7 @@ again: next_tail = (tail +sizeof (*cmd)) % iommu->cmd_buf_size; left = (head - next_tail) % iommu->cmd_buf_size; -if (left <=2 ) { +if (left <=0x20 ) {struct iommu_cmd sync_cmd;volatile u64 sem =0 ;int ret;
drivers/md/dm-crypt.c +5 -2
@@ -1322,12 +1322,15 @@ static int crypt_set_key(struct crypt_config *cc, char *key)if (!cc->key_size &&strcmp (key,"-" )) goto out; +/* clear the flag since following operations may invalidate previously valid key */ +clear_bit (DM_CRYPT_KEY_VALID , &cc->flags); +if (cc->key_size &&crypt_decode_key (cc->key, key, cc->key_size) <0 ) goto out; -set_bit (DM_CRYPT_KEY_VALID , &cc->flags); - r =crypt_setkey_allcpus (cc); +if (!r) +set_bit (DM_CRYPT_KEY_VALID , &cc->flags); out:/* Hex key string not needed after here, so wipe it. */
drivers/media/dvb/siano/smsusb.c +13 -4
@@ -181,11 +181,20 @@ static int smsusb_start_streaming(struct smsusb_device_t *dev)static int smsusb_sendrequest (void *context,void *buffer,size_t size) {struct smsusb_device_t *dev = (struct smsusb_device_t *) context; -int dummy; +struct SmsMsgHdr_ST *phdr; +int dummy, ret; -smsendian_handle_message_header ((struct SmsMsgHdr_ST *)buffer); -return usb_bulk_msg (dev->udev,usb_sndbulkpipe (dev->udev,2 ), - buffer, size, &dummy,1000 ); + phdr =kmalloc (size,GFP_KERNEL ); +if (!phdr) +return -ENOMEM ; +memcpy (phdr, buffer, size); + +smsendian_handle_message_header ((struct SmsMsgHdr_ST *)phdr); + ret =usb_bulk_msg (dev->udev,usb_sndbulkpipe (dev->udev,2 ), + phdr, size, &dummy,1000 ); + +kfree (phdr); +return ret; }static char *smsusb1_fw_lkup[] = {
drivers/media/rc/ite-cir.c +2 -0
@@ -263,6 +263,8 @@ static void ite_set_carrier_params(struct ite_dev *dev)if (allowance >ITE_RXDCR_MAX ) allowance =ITE_RXDCR_MAX ; + + use_demodulator = true; } }
drivers/media/video/davinci/vpfe_capture.c +1 -0
@@ -2002,6 +2002,7 @@ static __init int vpfe_probe(struct platform_device *pdev)v4l2_info (&vpfe_dev->v4l2_dev,"v4l2 sub device %s register fails\n" , sdinfo->name); + ret = -ENXIO ; goto probe_sd_out; } }
drivers/mmc/host/mxs-mmc.c +4 -2
@@ -386,6 +386,9 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host) cmd0 =BF_SSP (cmd->opcode,CMD0_CMD ); cmd1 = cmd->arg; +if (cmd->opcode ==MMC_STOP_TRANSMISSION ) + cmd0 |=BM_SSP_CMD0_APPEND_8CYC ; +if (host->sdio_irq_en) { ctrl0 |=BM_SSP_CTRL0_SDIO_IRQ_CHECK ; cmd0 |=BM_SSP_CMD0_CONT_CLKING_EN |BM_SSP_CMD0_SLOW_CLKING_EN ;
@@ -487,8 +490,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host) host->base + HW_SSP_BLOCK_SIZE); } -if ((cmd->opcode ==MMC_STOP_TRANSMISSION ) || - (cmd->opcode ==SD_IO_RW_EXTENDED )) +if (cmd->opcode ==SD_IO_RW_EXTENDED ) cmd0 |=BM_SSP_CMD0_APPEND_8CYC ; cmd1 = cmd->arg;
drivers/net/can/ti_hecc.c +12 -4
@@ -942,7 +942,12 @@ static int ti_hecc_probe(struct platform_device *pdev)netif_napi_add (ndev, &priv->napi, ti_hecc_rx_poll,HECC_DEF_NAPI_WEIGHT ); -clk_enable (priv->clk); + err =clk_prepare_enable (priv->clk); +if (err) { +dev_err (&pdev->dev,"clk_prepare_enable() failed\n" ); + goto probe_exit_clk; + } + err =register_candev (ndev);if (err) {dev_err (&pdev->dev,"register_candev() failed\n" );
@@ -972,7 +977,7 @@ static int __devexit ti_hecc_remove(struct platform_device *pdev)struct ti_hecc_priv *priv =netdev_priv (ndev);unregister_candev (ndev); -clk_disable (priv->clk); +clk_disable_unprepare (priv->clk);clk_put (priv->clk); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );iounmap (priv->base);
@@ -998,7 +1003,7 @@ static int ti_hecc_suspend(struct platform_device *pdev, pm_message_t state)hecc_set_bit (priv,HECC_CANMC ,HECC_CANMC_PDR ); priv->can.state =CAN_STATE_SLEEPING ; -clk_disable (priv->clk); +clk_disable_unprepare (priv->clk);return 0 ; }
@@ -1007,8 +1012,11 @@ static int ti_hecc_resume(struct platform_device *pdev) {struct net_device *dev =platform_get_drvdata (pdev);struct ti_hecc_priv *priv =netdev_priv (dev); +int err; -clk_enable (priv->clk); + err =clk_prepare_enable (priv->clk); +if (err) +return err;hecc_clear_bit (priv,HECC_CANMC ,HECC_CANMC_PDR ); priv->can.state =CAN_STATE_ERROR_ACTIVE ;
drivers/net/ethernet/korina.c +4 -4
@@ -906,10 +906,10 @@ static void korina_restart_task(struct work_struct *work)DMA_STAT_DONE |DMA_STAT_HALT |DMA_STAT_ERR , &lp->rx_dma_regs->dmasm); -korina_free_ring (dev); -napi_disable (&lp->napi); +korina_free_ring (dev); +if (korina_init (dev) <0 ) {printk (KERN_ERR "%s: cannot restart device\n" , dev->name);return ;
@@ -1070,12 +1070,12 @@ static int korina_close(struct net_device *dev) tmp = tmp |DMA_STAT_DONE |DMA_STAT_HALT |DMA_STAT_ERR ;writel (tmp, &lp->rx_dma_regs->dmasm); -korina_free_ring (dev); -napi_disable (&lp->napi);cancel_work_sync (&lp->restart_task); +korina_free_ring (dev); +free_irq (lp->rx_irq, dev);free_irq (lp->tx_irq, dev);free_irq (lp->ovr_irq, dev);
drivers/net/ethernet/marvell/sky2.c +13 -0
@@ -5165,6 +5165,19 @@ static SIMPLE_DEV_PM_OPS(sky2_pm_ops, sky2_suspend, sky2_resume);static void sky2_shutdown (struct pci_dev *pdev) { +struct sky2_hw *hw =pci_get_drvdata (pdev); +int port; + +for (port =0 ; port < hw->ports; port++) { +struct net_device *ndev = hw->dev[port]; + +rtnl_lock (); +if (netif_running (ndev)) { +dev_close (ndev); +netif_device_detach (ndev); + } +rtnl_unlock (); + }sky2_suspend (&pdev->dev);pci_wake_from_d3 (pdev,device_may_wakeup (&pdev->dev));pci_set_power_state (pdev, PCI_D3hot);
drivers/net/ethernet/mellanox/mlx4/cq.c +20 -18
@@ -78,13 +78,19 @@ void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn) {struct mlx4_cq *cq; +rcu_read_lock (); cq =radix_tree_lookup (&mlx4_priv (dev)->cq_table.tree, cqn & (dev->caps.num_cqs -1 )); +rcu_read_unlock (); +if (!cq) {mlx4_warn (dev,"Completion event for bogus CQ %08x\n" , cqn);return ; } +/* Acessing the CQ outside of rcu_read_lock is safe, because +* the CQ is freed only after interrupt handling is completed. +*/ ++cq->arm_sn; cq->comp (cq);
@@ -95,23 +101,19 @@ void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type)struct mlx4_cq_table *cq_table = &mlx4_priv (dev)->cq_table;struct mlx4_cq *cq; -spin_lock (&cq_table->lock); - +rcu_read_lock (); cq =radix_tree_lookup (&cq_table->tree, cqn & (dev->caps.num_cqs -1 )); -if (cq) -atomic_inc (&cq->refcount); - -spin_unlock (&cq_table->lock); +rcu_read_unlock ();if (!cq) { -mlx4_warn (dev,"Async event for bogus CQ %08x\n" , cqn); +mlx4_dbg (dev,"Async event for bogus CQ %08x\n" , cqn);return ; } +/* Acessing the CQ outside of rcu_read_lock is safe, because +* the CQ is freed only after interrupt handling is completed. +*/ cq->event (cq, event_type); - -if (atomic_dec_and_test (&cq->refcount)) -complete (&cq->free); } static int mlx4_SW2HW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
@@ -216,9 +218,9 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,if (err) goto err_put; -spin_lock_irq (&cq_table->lock); +spin_lock (&cq_table->lock); err =radix_tree_insert (&cq_table->tree, cq->cqn, cq); -spin_unlock_irq (&cq_table->lock); +spin_unlock (&cq_table->lock);if (err) goto err_cmpt_put;
@@ -255,9 +257,9 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,return 0 ; err_radix: -spin_lock_irq (&cq_table->lock); +spin_lock (&cq_table->lock);radix_tree_delete (&cq_table->tree, cq->cqn); -spin_unlock_irq (&cq_table->lock); +spin_unlock (&cq_table->lock); err_cmpt_put:mlx4_table_put (dev, &cq_table->cmpt_table, cq->cqn);
@@ -282,11 +284,11 @@ void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq)if (err)mlx4_warn (dev,"HW2SW_CQ failed (%d) for CQN %06x\n" , err, cq->cqn); -synchronize_irq (priv->eq_table.eq[cq->vector].irq); - -spin_lock_irq (&cq_table->lock); +spin_lock (&cq_table->lock);radix_tree_delete (&cq_table->tree, cq->cqn); -spin_unlock_irq (&cq_table->lock); +spin_unlock (&cq_table->lock); + +synchronize_irq (priv->eq_table.eq[cq->vector].irq);if (atomic_dec_and_test (&cq->refcount))complete (&cq->free);
drivers/net/ethernet/mellanox/mlx4/en_rx.c +7 -1
@@ -328,8 +328,14 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv) ring->cqn = priv->rx_cq[ring_ind].mcq.cqn; ring->stride = stride; -if (ring->stride <=TXBB_SIZE ) +if (ring->stride <=TXBB_SIZE ) { +/* Stamp first unused send wqe */ +__be32 *ptr = (__be32 *)ring->buf; +__be32 stamp =cpu_to_be32 (1 <<STAMP_SHIFT ); + *ptr = stamp; +/* Move pointer to start of rx section */ ring->buf +=TXBB_SIZE ; + } ring->log_stride =ffs (ring->stride) -1 ; ring->buf_size = ring->size * ring->stride;
drivers/net/ethernet/mellanox/mlx4/icm.c +6 -1
@@ -113,8 +113,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,if (!buf)return -ENOMEM ; +if (offset_in_page (buf)) { +dma_free_coherent (dev,PAGE_SIZE << order, + buf,sg_dma_address (mem)); +return -ENOMEM ; + } +sg_set_buf (mem, buf,PAGE_SIZE << order); -BUG_ON (mem->offset);sg_dma_len (mem) =PAGE_SIZE << order;return 0 ; }
drivers/net/ethernet/xilinx/xilinx_emaclite.c +7 -3
@@ -398,7 +398,7 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,* * Return: Total number of bytes received */ -static u16 xemaclite_recv_data (struct net_local *drvdata,u8 *data) +static u16 xemaclite_recv_data (struct net_local *drvdata,u8 *data,int maxlen) {void __iomem *addr;u16 length, proto_type;
@@ -438,7 +438,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)/* Check if received ethernet frame is a raw ethernet frame * or an IP packet or an ARP packet */ -if (proto_type > (ETH_FRAME_LEN +ETH_FCS_LEN )) { +if (proto_type >ETH_DATA_LEN ) {if (proto_type ==ETH_P_IP ) { length = ((ntohl(in_be32(addr +
@@ -446,6 +446,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data) XEL_RXBUFF_OFFSET)) >> XEL_HEADER_SHIFT) & XEL_RPLR_LENGTH_MASK); + length =min_t (u16, length,ETH_DATA_LEN ); length +=ETH_HLEN +ETH_FCS_LEN ; }else if (proto_type ==ETH_P_ARP )
@@ -458,6 +459,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)/* Use the length in the frame, plus the header and trailer */ length = proto_type +ETH_HLEN +ETH_FCS_LEN ; +if (WARN_ON (length > maxlen)) + length = maxlen; +/* Read from the EmacLite device */ xemaclite_aligned_read ((u32 __force *) (addr +XEL_RXBUFF_OFFSET ), data, length);
@@ -632,7 +636,7 @@ static void xemaclite_rx_handler(struct net_device *dev)skb_reserve (skb,2 ); - len =xemaclite_recv_data (lp, (u8 *) skb->data); + len =xemaclite_recv_data (lp, (u8 *) skb->data, len);if (!len) { dev->stats.rx_errors++;
drivers/net/macvtap.c +2 -2
@@ -687,7 +687,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,size_t linear;if (q->flags &IFF_VNET_HDR ) { - vnet_hdr_len = q->vnet_hdr_sz; + vnet_hdr_len =ACCESS_ONCE (q->vnet_hdr_sz); err = -EINVAL ;if (len < vnet_hdr_len)
@@ -817,7 +817,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,if (q->flags &IFF_VNET_HDR ) {struct virtio_net_hdr vnet_hdr; - vnet_hdr_len = q->vnet_hdr_sz; + vnet_hdr_len =ACCESS_ONCE (q->vnet_hdr_sz);if ((len -= vnet_hdr_len) <0 )return -EINVAL ;
drivers/net/tun.c +13 -7
@@ -625,9 +625,11 @@ static ssize_t tun_get_user(struct tun_struct *tun, }if (tun->flags &TUN_VNET_HDR ) { -if (len < tun->vnet_hdr_sz) +int vnet_hdr_sz =ACCESS_ONCE (tun->vnet_hdr_sz); + +if (len < vnet_hdr_sz)return -EINVAL ; - len -= tun->vnet_hdr_sz; + len -= vnet_hdr_sz;if (memcpy_fromiovecend ((void *)&gso, iv, offset,sizeof (gso)))return -EFAULT ;
@@ -638,7 +640,7 @@ static ssize_t tun_get_user(struct tun_struct *tun,if (gso.hdr_len > len)return -EINVAL ; - offset += tun->vnet_hdr_sz; + offset += vnet_hdr_sz; }if ((tun->flags &TUN_TYPE_MASK ) ==TUN_TAP_DEV ) {
@@ -767,12 +769,16 @@ static ssize_t tun_put_user(struct tun_struct *tun, {struct tun_pi pi = {0 , skb->protocol };ssize_t total =0 ; +int vnet_hdr_sz =0 ; + +if (tun->flags &TUN_VNET_HDR ) + vnet_hdr_sz =ACCESS_ONCE (tun->vnet_hdr_sz);if (!(tun->flags &TUN_NO_PI )) {if ((len -=sizeof (pi)) <0 )return -EINVAL ; -if (len < skb->len) { +if (len < skb->len + vnet_hdr_sz) {/* Packet will be striped */ pi.flags |=TUN_PKT_STRIP ; }
@@ -782,9 +788,9 @@ static ssize_t tun_put_user(struct tun_struct *tun, total +=sizeof (pi); } -if (tun->flags &TUN_VNET_HDR ) { +if (vnet_hdr_sz) {struct virtio_net_hdr gso = {0 };/* no info leak */ -if ((len -= tun->vnet_hdr_sz) <0 ) +if ((len -= vnet_hdr_sz) <0 )return -EINVAL ;if (skb_is_gso (skb)) {
@@ -827,7 +833,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,if (unlikely (memcpy_toiovecend (iv, (void *)&gso, total,sizeof (gso))))return -EFAULT ; - total += tun->vnet_hdr_sz; + total += vnet_hdr_sz; } len =min_t (int, skb->len, len);
drivers/net/usb/catc.c +34 -22
90 lines not on this page · raw message
drivers/net/usb/rtl8150.c +27 -7
@@ -178,16 +178,36 @@ static const char driver_name [] = "rtl8150";*/ static int get_registers (rtl8150_t * dev,u16 indx,u16 size,void *data) { -return usb_control_msg (dev->udev,usb_rcvctrlpipe (dev->udev,0 ), -RTL8150_REQ_GET_REGS ,RTL8150_REQT_READ , - indx,0 , data, size,500 ); +void *buf; +int ret; + + buf =kmalloc (size,GFP_NOIO ); +if (!buf) +return -ENOMEM ; + + ret =usb_control_msg (dev->udev,usb_rcvctrlpipe (dev->udev,0 ), +RTL8150_REQ_GET_REGS ,RTL8150_REQT_READ , + indx,0 , buf, size,500 ); +if (ret >0 && ret <= size) +memcpy (data, buf, ret); +kfree (buf); +return ret; } -static int set_registers (rtl8150_t * dev,u16 indx,u16 size,void *data) +static int set_registers (rtl8150_t * dev,u16 indx,u16 size,const void *data) { -return usb_control_msg (dev->udev,usb_sndctrlpipe (dev->udev,0 ), -RTL8150_REQ_SET_REGS ,RTL8150_REQT_WRITE , - indx,0 , data, size,500 ); +void *buf; +int ret; + + buf =kmemdup (data, size,GFP_NOIO ); +if (!buf) +return -ENOMEM ; + + ret =usb_control_msg (dev->udev,usb_sndctrlpipe (dev->udev,0 ), +RTL8150_REQ_SET_REGS ,RTL8150_REQT_WRITE , + indx,0 , buf, size,500 ); +kfree (buf); +return ret; }static void ctrl_callback (struct urb *urb)
drivers/net/xen-netfront.c +2 -2
@@ -1404,6 +1404,8 @@ static void xennet_disconnect_backend(struct netfront_info *info)spin_unlock_irq (&info->tx_lock);spin_unlock_bh (&info->rx_lock); +del_timer_sync (&info->rx_refill_timer); +if (info->netdev->irq)unbind_from_irqhandler (info->netdev->irq, info->netdev); info->evtchn = info->netdev->irq =0 ;
@@ -1940,8 +1942,6 @@ static int __devexit xennet_remove(struct xenbus_device *dev)unregister_netdev (info->netdev); -del_timer_sync (&info->rx_refill_timer); -free_percpu (info->stats);free_netdev (info->netdev);
drivers/pci/hotplug/rpadlpar_core.c +9 -1
@@ -259,8 +259,13 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn)static int dlpar_add_vio_slot (char *drc_name,struct device_node *dn) { -if (vio_find_node (dn)) +struct vio_dev *vio_dev; + + vio_dev =vio_find_node (dn); +if (vio_dev) { +put_device (&vio_dev->dev);return -EINVAL ; + }if (!vio_register_device_node (dn)) { printk(KERN_ERR
@@ -336,6 +341,9 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)return -EINVAL ;vio_unregister_device (vio_dev); + +put_device (&vio_dev->dev); +return 0 ; }
drivers/pci/pci.c +4 -0
@@ -1763,6 +1763,10 @@ bool pci_dev_run_wake(struct pci_dev *dev)if (!dev->pme_support)return false; +/* PME-capable in principle, but not from the intended sleep state */ +if (!pci_pme_capable (dev,pci_target_state (dev))) +return false; +while (bus->parent) {struct pci_dev *bridge = bus->self;
drivers/platform/x86/intel_mid_powerbtn.c +1 -1
@@ -72,7 +72,7 @@ static int __devinit mfld_pb_probe(struct platform_device *pdev)input_set_capability (input,EV_KEY ,KEY_POWER ); - error =request_threaded_irq (irq,NULL , mfld_pb_isr,0 , + error =request_threaded_irq (irq,NULL , mfld_pb_isr,IRQF_ONESHOT ,DRIVER_NAME , input);if (error) { dev_err(&pdev->dev, "Unable to request irq %d for mfld power"
drivers/s390/char/vmlogrdr.c +1 -1
@@ -876,7 +876,7 @@ static int __init vmlogrdr_init(void) goto cleanup;for (i=0 ; i <MAXMINOR ; ++i ) { - sys_ser[i].buffer = (char *)get_zeroed_page (GFP_KERNEL ); + sys_ser[i].buffer = (char *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sys_ser[i].buffer) { rc = -ENOMEM ;break ;
drivers/s390/scsi/zfcp_dbf.c +14 -3
@@ -282,11 +282,12 @@ void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter,/** -* zfcp_dbf_rec_run - trace event related to running recovery +* zfcp_dbf_rec_run_lvl - trace event related to running recovery +* @level: trace level to be used for event * @tag: identifier for event * @erp: erp_action running */ -void zfcp_dbf_rec_run (char *tag,struct zfcp_erp_action *erp) +void zfcp_dbf_rec_run_lvl (int level,char *tag,struct zfcp_erp_action *erp) {struct zfcp_dbf *dbf = erp->adapter->dbf;struct zfcp_dbf_rec *rec = &dbf->rec_buf;
@@ -312,11 +313,21 @@ void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp)else rec->u.run.rec_count =atomic_read (&erp->adapter->erp_counter); -debug_event (dbf->rec,1 , rec,sizeof (*rec)); +debug_event (dbf->rec, level, rec,sizeof (*rec));spin_unlock_irqrestore (&dbf->rec_lock, flags); }/** +* zfcp_dbf_rec_run - trace event related to running recovery +* @tag: identifier for event +* @erp: erp_action running +*/ +void zfcp_dbf_rec_run (char *tag,struct zfcp_erp_action *erp) +{ +zfcp_dbf_rec_run_lvl (1 , tag, erp); +} + +/** * zfcp_dbf_rec_run_wka - trace wka port event with info like running recovery * @tag: identifier for event * @wka_port: well known address port
drivers/s390/scsi/zfcp_dbf.h +39 -2
63 lines not on this page · raw message
drivers/s390/scsi/zfcp_erp.c +59 -2
85 lines not on this page · raw message
drivers/s390/scsi/zfcp_ext.h +3 -1
@@ -3,7 +3,7 @@* * External function declarations. * -* Copyright IBM Corp. 2002, 2015 +* Copyright IBM Corp. 2002, 2016 */ #ifndef ZFCP_EXT_H
@@ -49,6 +49,8 @@ extern void zfcp_dbf_adapter_unregister(struct zfcp_adapter *);extern void zfcp_dbf_rec_trig (char *,struct zfcp_adapter *,struct zfcp_port *,struct scsi_device *,u8 ,u8 );extern void zfcp_dbf_rec_run (char *,struct zfcp_erp_action *); +extern void zfcp_dbf_rec_run_lvl (int level,char *tag, +struct zfcp_erp_action *erp);extern void zfcp_dbf_rec_run_wka (char *,struct zfcp_fc_wka_port *,u64 );extern void zfcp_dbf_hba_fsf_uss (char *,struct zfcp_fsf_req *);extern void zfcp_dbf_hba_fsf_res (char *,int ,struct zfcp_fsf_req *);
drivers/s390/scsi/zfcp_fsf.c +4 -4
@@ -1577,7 +1577,7 @@ out:int zfcp_fsf_open_wka_port (struct zfcp_fc_wka_port *wka_port) {struct zfcp_qdio *qdio = wka_port->adapter->qdio; -struct zfcp_fsf_req *req =NULL ; +struct zfcp_fsf_req *req;int retval = -EIO ;spin_lock_irq (&qdio->req_q_lock);
@@ -1606,7 +1606,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)zfcp_fsf_req_free (req); out:spin_unlock_irq (&qdio->req_q_lock); -if (req && !IS_ERR (req)) +if (!retval)zfcp_dbf_rec_run_wka ("fsowp_1" , wka_port, req->req_id);return retval; }
@@ -1632,7 +1632,7 @@ static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)int zfcp_fsf_close_wka_port (struct zfcp_fc_wka_port *wka_port) {struct zfcp_qdio *qdio = wka_port->adapter->qdio; -struct zfcp_fsf_req *req =NULL ; +struct zfcp_fsf_req *req;int retval = -EIO ;spin_lock_irq (&qdio->req_q_lock);
@@ -1661,7 +1661,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)zfcp_fsf_req_free (req); out:spin_unlock_irq (&qdio->req_q_lock); -if (req && !IS_ERR (req)) +if (!retval)zfcp_dbf_rec_run_wka ("fscwp_1" , wka_port, req->req_id);return retval; }
drivers/s390/scsi/zfcp_fsf.h +2 -1
@@ -3,7 +3,7 @@* * Interface to the FSF support functions. * -* Copyright IBM Corp. 2002, 2015 +* Copyright IBM Corp. 2002, 2016 */ #ifndef FSF_H
@@ -86,6 +86,7 @@#define FSF_APP_TAG_CHECK_FAILURE 0x00000082#define FSF_REF_TAG_CHECK_FAILURE 0x00000083#define FSF_ADAPTER_STATUS_AVAILABLE 0x000000AD +#define FSF_FCP_RSP_AVAILABLE 0x000000AF#define FSF_UNKNOWN_COMMAND 0x000000E2#define FSF_UNKNOWN_OP_SUBTYPE 0x000000E3#define FSF_INVALID_COMMAND_OPTION 0x000000E5
drivers/s390/scsi/zfcp_reqlist.h +29 -1
@@ -4,7 +4,7 @@* Data structure and helper functions for tracking pending FSF * requests. * -* Copyright IBM Corporation 2009 +* Copyright IBM Corp. 2009, 2016 */ #ifndef ZFCP_REQLIST_H
@@ -180,4 +180,32 @@ static inline void zfcp_reqlist_move(struct zfcp_reqlist *rl, spin_unlock_irqrestore(&rl->lock, flags); } +/** +* zfcp_reqlist_apply_for_all() - apply a function to every request. +* @rl: the requestlist that contains the target requests. +* @f: the function to apply to each request; the first parameter of the +* function will be the target-request; the second parameter is the same +* pointer as given with the argument @data. +* @data: freely chosen argument; passed through to @f as second parameter. +* +* Uses :c:macro:`list_for_each_entry` to iterate over the lists in the hash- +* table (not a 'safe' variant, so don't modify the list). +* +* Holds @rl->lock over the entire request-iteration. +*/ +static inline void +zfcp_reqlist_apply_for_all (struct zfcp_reqlist *rl, +void (*f)(struct zfcp_fsf_req *,void *),void *data) +{ +struct zfcp_fsf_req *req; +unsigned long flags; +unsigned int i; + +spin_lock_irqsave (&rl->lock, flags); +for (i =0 ; i <ZFCP_REQ_LIST_BUCKETS ; i++) +list_for_each_entry (req, &rl->buckets[i], list) +f (req, data); +spin_unlock_irqrestore (&rl->lock, flags); +} +#endif /* ZFCP_REQLIST_H */
drivers/s390/scsi/zfcp_scsi.c +56 -5
86 lines not on this page · raw message
drivers/scsi/mvsas/mv_94xx.c +1 -1
@@ -622,7 +622,7 @@ static void mvs_94xx_command_active(struct mvs_info *mvi, u32 slot_idx) {u32 tmp; tmp =mvs_cr32 (mvi,MVS_COMMAND_ACTIVE +(slot_idx >>3 )); -if (tmp &&1 << (slot_idx %32 )) { +if (tmp &1 << (slot_idx %32 )) {mv_printk ("command active %08X, slot [%x].\n" , tmp, slot_idx);mvs_cw32 (mvi,MVS_COMMAND_ACTIVE + (slot_idx >>3 ),1 << (slot_idx %32 ));
drivers/scsi/scsi_sysfs.c +0 -4
@@ -864,10 +864,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)struct request_queue *rq = sdev->request_queue;struct scsi_target *starget = sdev->sdev_target; - error =scsi_device_set_state (sdev,SDEV_RUNNING ); -if (error) -return error; - error =scsi_target_add (starget);if (error)return error;
drivers/scsi/sg.c +4 -0
@@ -1710,6 +1710,10 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd) iov_count =iov_shorten (iov, iov_count, hp->dxfer_len); len = hp->dxfer_len; } +if (len ==0 ) { +kfree (iov); +return -EINVAL ; + } res = blk_rq_map_user_iov(q, rq, md, (struct sg_iovec *)iov, iov_count,
drivers/ssb/pci.c +1 -0
@@ -713,6 +713,7 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus, ssb_printk(KERN_WARNING PFX "WARNING: Using"" fallback SPROM failed (err %d)\n" , err); + goto out_free; }else { ssb_dprintk(KERN_DEBUG PFX "Using SPROM"" revision %d provided by"
drivers/staging/gma500/psb_drv.c +3 -0
@@ -1185,6 +1185,9 @@ static struct drm_driver driver = { .open = drm_open, .release = drm_release, .unlocked_ioctl = psb_unlocked_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif .mmap = drm_gem_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/staging/hv/netvsc_drv.c +4 -0
@@ -52,6 +52,9 @@ struct net_device_context {/* Need this many pages to handle worst case fragmented packet */ #define PACKET_PAGES_HIWATER (MAX_SKB_FRAGS + 2) +/* Restrict GSO size to account for NVGRE */ +#define NETVSC_GSO_MAX_SIZE 62768 +static int ring_size =128 ;module_param (ring_size, int,S_IRUGO );MODULE_PARM_DESC (ring_size,"Ring buffer size (# of pages)" );
@@ -363,6 +366,7 @@ static int netvsc_probe(struct hv_device *dev,SET_ETHTOOL_OPS (net, ðtool_ops);SET_NETDEV_DEV (net, &dev->device); +netif_set_gso_max_size (net,NETVSC_GSO_MAX_SIZE ); ret =register_netdev (net);if (ret !=0 ) {
drivers/staging/iio/adc/ad7606_core.c +1 -1
@@ -185,7 +185,7 @@ static ssize_t ad7606_store_oversampling_ratio(struct device *dev,mutex_lock (&indio_dev->mlock);gpio_set_value (st->pdata->gpio_os0, (ret >>0 ) &1 );gpio_set_value (st->pdata->gpio_os1, (ret >>1 ) &1 ); -gpio_set_value (st->pdata->gpio_os1, (ret >>2 ) &1 ); +gpio_set_value (st->pdata->gpio_os2, (ret >>2 ) &1 ); st->oversampling = lval;mutex_unlock (&indio_dev->mlock);
drivers/staging/vme/bridges/vme_ca91cx42.c +1 -1
@@ -466,7 +466,7 @@ static int ca91cx42_slave_get(struct vme_slave_resource *image, int *enabled, vme_bound =ioread32 (bridge->base +CA91CX42_VSI_BD [i]); pci_offset =ioread32 (bridge->base +CA91CX42_VSI_TO [i]); - *pci_base = (dma_addr_t )vme_base + pci_offset; + *pci_base = (dma_addr_t)*vme_base + pci_offset; *size = (unsigned long long )((vme_bound - *vme_base) + granularity); *enabled =0 ;
drivers/target/iscsi/iscsi_target_tpg.c +0 -1
@@ -253,7 +253,6 @@ err_out:iscsi_release_param_list (tpg->param_list); tpg->param_list =NULL ; } -kfree (tpg);return -ENOMEM ; }
drivers/thermal/thermal_sys.c +1 -1
@@ -486,7 +486,7 @@ temp_crit_show(struct device *dev, struct device_attribute *attr,long temperature;int ret; - ret = tz->ops->get_trip_temp (tz,0 , &temperature); + ret = tz->ops->get_crit_temp (tz, &temperature);if (ret)return ret;
drivers/tty/n_hdlc.c +69 -74
279 lines not on this page · raw message
drivers/tty/sysrq.c +2 -2
@@ -763,8 +763,8 @@ static const struct input_device_id sysrq_ids[] = { { .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT, - .evbit = { BIT_MASK(EV_KEY) }, - .keybit = { BIT_MASK(KEY_LEFTALT) }, + .evbit = { [BIT_WORD(EV_KEY)] = BIT_MASK(EV_KEY) }, + .keybit = { [BIT_WORD(KEY_LEFTALT)] = BIT_MASK(KEY_LEFTALT) }, }, { }, };
drivers/usb/class/cdc-acm.c +1 -0
@@ -1541,6 +1541,7 @@ static const struct usb_device_id acm_ids[] = { .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ }, { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */ + { USB_DEVICE(0x2184, 0x0036) }, /* GW Instek AFG-125 */ { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */ },/* Motorola H24 HSPA module: */
drivers/usb/core/config.c +10 -0
@@ -207,6 +207,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,if (ifp->desc.bNumEndpoints >= num_ep) goto skip_to_next_endpoint_or_interface_descriptor; +/* Check for duplicate endpoint addresses */ +for (i =0 ; i < ifp->desc.bNumEndpoints; ++i) { +if (ifp->endpoint[i].desc.bEndpointAddress == + d->bEndpointAddress) { +dev_warn (ddev,"config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n" , + cfgno, inum, asnum, d->bEndpointAddress); + goto skip_to_next_endpoint_or_interface_descriptor; + } + } + endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints;
drivers/usb/core/quirks.c +4 -0
@@ -36,6 +36,10 @@ static const struct usb_device_id usb_quirk_list[] = {/* CBM - Flash disk */ { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, + /* WORLDE easy key (easykey.25) MIDI controller */ + { USB_DEVICE(0x0218, 0x0401), .driver_info = + USB_QUIRK_CONFIG_INTF_STRINGS }, + /* HP 5300/5370C scanner */ { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
drivers/usb/gadget/composite.c +9 -5
@@ -156,7 +156,7 @@ int config_ep_by_speed(struct usb_gadget *g, ep_found:/* commit results */ - _ep->maxpacket =usb_endpoint_maxp (chosen_desc); + _ep->maxpacket =usb_endpoint_maxp (chosen_desc) &0x7ff ; _ep->desc = chosen_desc; _ep->comp_desc =NULL ; _ep->maxburst =0 ;
@@ -1126,9 +1126,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value =min (w_length, (u16 )1 );break ; -/* function drivers must handle get/set altsetting; if there's -* no get() method, we know only altsetting zero works. -*/ +/* function drivers must handle get/set altsetting */ case USB_REQ_SET_INTERFACE :if (ctrl->bRequestType !=USB_RECIP_INTERFACE ) goto unknown;
@@ -1137,7 +1135,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) f = cdev->config->interface[intf];if (!f)break ; -if (w_value && !f->set_alt) + +/* +* If there's no get_alt() method, we know only altsetting zero +* works. There is no need to check if set_alt() is not NULL +* as we check this in usb_add_function(). +*/ +if (w_value && !f->get_alt)break ; value = f->set_alt (f, w_index, w_value);if (value ==USB_GADGET_DELAYED_STATUS ) {
drivers/usb/gadget/dummy_hcd.c +3 -3
@@ -261,7 +261,7 @@ static void nuke (struct dummy *dum, struct dummy_ep *ep)static void stop_activity (struct dummy *dum) { -struct dummy_ep *ep; +int i;/* prevent any more requests */ dum->address =0 ;
@@ -269,8 +269,8 @@ stop_activity (struct dummy *dum)/* The timer is left running so that outstanding URBs can fail */ /* nuke any pending requests first, so driver i/o is quiesced */ -list_for_each_entry (ep, &dum->gadget.ep_list, ep.ep_list) - nuke (dum, ep); +for (i =0 ; i <DUMMY_ENDPOINTS ; ++i) +nuke (dum, &dum->ep[i]);/* driver now does any non-usb quiescing necessary */ }
drivers/usb/gadget/inode.c +12 -5
@@ -1196,7 +1196,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)/* data and/or status stage for control request */ }else if (dev->state ==STATE_DEV_SETUP ) { -/* IN DATA+STATUS caller makes len <= wLength */ + len =min_t (size_t, len, dev->setup_wLength);if (dev->setup_in) { retval =setup_req (dev->gadget->ep0, dev->req, len);if (retval ==0 ) {
@@ -1841,10 +1841,12 @@ static struct usb_gadget_driver probe_driver = {* such as configuration notifications. */ -static int is_valid_config (struct usb_config_descriptor *config) +static int is_valid_config (struct usb_config_descriptor *config, +unsigned int total) {return config->bDescriptorType ==USB_DT_CONFIG && config->bLength ==USB_DT_CONFIG_SIZE + && total >=USB_DT_CONFIG_SIZE && config->bConfigurationValue !=0 && (config->bmAttributes &USB_CONFIG_ATT_ONE ) !=0 && (config->bmAttributes &USB_CONFIG_ATT_WAKEUP ) ==0 ;
@@ -1861,7 +1863,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)u32 tag;char *kbuf; -if (len < (USB_DT_CONFIG_SIZE +USB_DT_DEVICE_SIZE +4 )) +if ((len < (USB_DT_CONFIG_SIZE +USB_DT_DEVICE_SIZE +4 )) || + (len >PAGE_SIZE *4 ))return -EINVAL ;/* we might need to change message format someday */
@@ -1885,7 +1888,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)/* full or low speed config */ dev->config = (void *) kbuf; total =le16_to_cpu (dev->config->wTotalLength); -if (!is_valid_config (dev->config) || total >= length) +if (!is_valid_config (dev->config, total) || + total > length -USB_DT_DEVICE_SIZE ) goto fail; kbuf += total; length -= total;
@@ -1894,10 +1898,13 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)if (kbuf [1 ] ==USB_DT_CONFIG ) { dev->hs_config = (void *) kbuf; total =le16_to_cpu (dev->hs_config->wTotalLength); -if (!is_valid_config (dev->hs_config) || total >= length) +if (!is_valid_config (dev->hs_config, total) || + total > length -USB_DT_DEVICE_SIZE ) goto fail; kbuf += total; length -= total; + }else { + dev->hs_config =NULL ; }/* could support multiple configs, using another encoding! */
drivers/usb/host/uhci-pci.c +4 -0
@@ -129,6 +129,10 @@ static int uhci_pci_init(struct usb_hcd *hcd)if (to_pci_dev (uhci_dev (uhci))->vendor ==PCI_VENDOR_ID_HP ) uhci->wait_for_hp =1 ; +/* Intel controllers use non-PME wakeup signalling */ +if (to_pci_dev (uhci_dev (uhci))->vendor ==PCI_VENDOR_ID_INTEL ) +device_set_run_wake (uhci_dev (uhci),1 ); +/* Set up pointers to PCI-specific functions */ uhci->reset_hc = uhci_pci_reset_hc; uhci->check_and_reset_hc = uhci_pci_check_and_reset_hc;
drivers/usb/host/xhci-mem.c +38 -4
66 lines not on this page · raw message
drivers/usb/host/xhci-ring.c +0 -6
@@ -969,12 +969,6 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)spin_lock_irqsave (&xhci->lock, flags); ep->stop_cmds_pending--; -if (xhci->xhc_state &XHCI_STATE_DYING ) { -xhci_dbg (xhci,"Stop EP timer ran, but another timer marked " -"xHCI as DYING, exiting.\n" ); -spin_unlock_irqrestore (&xhci->lock, flags); -return ; - }if (!(ep->stop_cmds_pending ==0 && (ep->ep_state &EP_HALT_PENDING ))) {xhci_dbg (xhci,"Stop EP timer ran, but no command pending, " "exiting.\n" );
drivers/usb/host/xhci.c +0 -12
@@ -1549,18 +1549,6 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)xhci_urb_free_priv (xhci, urb_priv);return ret; } -if ((xhci->xhc_state &XHCI_STATE_DYING ) || - (xhci->xhc_state &XHCI_STATE_HALTED )) { -xhci_dbg (xhci,"Ep 0x%x: URB %p to be canceled on " -"non-responsive xHCI host.\n" , - urb->ep->desc.bEndpointAddress, urb); -/* Let the stop endpoint command watchdog timer (which set this -* state) finish cleaning up the endpoint TD lists. We must -* have caught it in the middle of dropping a lock and giving -* back an URB. -*/ - goto done; - }xhci_dbg (xhci,"Cancel URB %p\n" , urb);xhci_dbg (xhci,"Event ring:\n" );
drivers/usb/musb/musbhsdma.h +1 -1
@@ -161,5 +161,5 @@ struct musb_dma_controller {void __iomem *base;u8 channel_count;u8 used_channels; -u8 irq; +int irq; };
drivers/usb/serial/ch341.c +117 -75
344 lines not on this page · raw message
drivers/usb/serial/cyberjack.c +3 -0
@@ -122,6 +122,9 @@ static int cyberjack_startup(struct usb_serial *serial)dbg ("%s" , __func__); +if (serial->num_bulk_out < serial->num_ports) +return -ENODEV ; +/* allocate the private data structure */ priv =kmalloc (sizeof (struct cyberjack_private ),GFP_KERNEL );if (!priv)
drivers/usb/serial/garmin_gps.c +1 -0
@@ -1075,6 +1075,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,"%s - usb_submit_urb(write bulk) failed with status = %d\n" , __func__, status); count = status; +kfree (buffer); }/* we are done with this urb, so let the host driver
drivers/usb/serial/io_edgeport.c +5 -0
@@ -2936,6 +2936,11 @@ static int edge_startup(struct usb_serial *serial)EDGE_COMPATIBILITY_MASK1 , EDGE_COMPATIBILITY_MASK2 }; +if (serial->num_bulk_in <1 || serial->num_interrupt_in <1 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + dev = serial->dev;/* create our private serial structure */
drivers/usb/serial/io_ti.c +14 -2
@@ -1500,7 +1500,7 @@ stayinbootmode:dbg ("%s - STAYING IN BOOT MODE" , __func__); serial->product_info.TiMode =TI_MODE_BOOT ; -return 0 ; +return 1 ; }
@@ -2642,6 +2642,13 @@ static int edge_startup(struct usb_serial *serial) dev = serial->dev; +/* Make sure we have the required endpoints when in download mode. */ +if (serial->interface->cur_altsetting->desc.bNumEndpoints >1 ) { +if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) +return -ENODEV ; + } +/* create our private serial structure */ edge_serial =kzalloc (sizeof (struct edgeport_serial ),GFP_KERNEL );if (edge_serial ==NULL ) {
@@ -2653,11 +2660,14 @@ static int edge_startup(struct usb_serial *serial)usb_set_serial_data (serial, edge_serial); status =download_fw (edge_serial); -if (status) { +if (status <0 ) {kfree (edge_serial);return status; } +if (status >0 ) +return 1 ;/* bind but do not register any ports */ +/* set up our port private structures */ for (i =0 ; i < serial->num_ports; ++i) { edge_port =kzalloc (sizeof (struct edgeport_port ),GFP_KERNEL );
@@ -2708,6 +2718,8 @@ static void edge_release(struct usb_serial *serial)for (i =0 ; i < serial->num_ports; ++i) { edge_port =usb_get_serial_port_data (serial->port[i]); +if (!edge_port) +continue ;kfifo_free (&edge_port->write_fifo);kfree (edge_port); }
drivers/usb/serial/iuu_phoenix.c +5 -0
@@ -112,7 +112,12 @@ static int iuu_alloc_buf(struct iuu_private *priv)static int iuu_startup (struct usb_serial *serial) { +unsigned char num_ports = serial->num_ports;struct iuu_private *priv; + +if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports) +return -ENODEV ; + priv =kzalloc (sizeof (struct iuu_private ),GFP_KERNEL );dbg ("%s- priv allocation success" , __func__);if (!priv)
drivers/usb/serial/keyspan_pda.c +7 -1
@@ -806,9 +806,15 @@ MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");static int keyspan_pda_startup (struct usb_serial *serial) { - +unsigned char num_ports = serial->num_ports;struct keyspan_pda_private *priv; +if (serial->num_bulk_out < num_ports || + serial->num_interrupt_in < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } +/* allocate the private data structures for all ports. Well, for all one ports. */
drivers/usb/serial/kl5kusb105.c +26 -9
@@ -338,7 +338,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) rc =usb_serial_generic_open (tty, port);if (rc) { retval = rc; - goto exit; + goto err_free_cfg; } rc = usb_control_msg(port->serial->dev,
@@ -353,21 +353,38 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)if (rc <0 ) {dev_err (&port->dev,"Enabling read failed (error = %d)\n" , rc); retval = rc; + goto err_generic_close; }else dbg ("%s - enabled reading" , __func__); rc =klsi_105_get_line_state (port, &line_state); -if (rc >=0 ) { -spin_lock_irqsave (&priv->lock, flags); - priv->line_state = line_state; -spin_unlock_irqrestore (&priv->lock, flags); -dbg ("%s - read line state 0x%lx" , __func__, line_state); - retval =0 ; - }else +if (rc <0 ) { retval = rc; + goto err_disable_read; + } + +spin_lock_irqsave (&priv->lock, flags); + priv->line_state = line_state; +spin_unlock_irqrestore (&priv->lock, flags); +dev_dbg (&port->dev,"%s - read line state 0x%lx\n" , __func__, + line_state); -exit: +return 0 ; + +err_disable_read: +usb_control_msg (port->serial->dev, +usb_sndctrlpipe (port->serial->dev,0 ), +KL5KUSB105A_SIO_CONFIGURE , +USB_TYPE_VENDOR |USB_DIR_OUT , +KL5KUSB105A_SIO_CONFIGURE_READ_OFF , +0 ,/* index */ +NULL ,0 , +KLSI_TIMEOUT ); +err_generic_close: +usb_serial_generic_close (port); +err_free_cfg:kfree (cfg); +return retval; }
drivers/usb/serial/kobil_sct.c +5 -0
@@ -150,6 +150,11 @@ static int kobil_startup(struct usb_serial *serial)struct usb_host_interface *altsetting;struct usb_host_endpoint *endpoint; +if (serial->num_interrupt_out < serial->num_ports) { +dev_err (&serial->interface->dev,"missing interrupt-out endpoint\n" ); +return -ENODEV ; + } + priv =kmalloc (sizeof (struct kobil_private ),GFP_KERNEL );if (!priv)return -ENOMEM ;
drivers/usb/serial/mos7720.c +21 -30
105 lines not on this page · raw message
drivers/usb/serial/mos7840.c +7 -3
@@ -1071,9 +1071,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) serial, serial->port[0]->interrupt_in_urb->interval); -/* start interrupt read for mos7840 * -* will continue as long as mos7840 is connected */ - +/* start interrupt read for mos7840 */ response =usb_submit_urb (serial->port[0 ]->interrupt_in_urb,GFP_KERNEL );
@@ -2386,6 +2384,12 @@ static int mos7840_startup(struct usb_serial *serial)return -1 ; } +if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + dev = serial->dev;dbg ("%s" ,"Entering..." );
drivers/usb/serial/omninet.c +6 -0
@@ -152,6 +152,12 @@ static int omninet_attach(struct usb_serial *serial)struct omninet_data *od;struct usb_serial_port *port = serial->port[0 ]; +/* The second bulk-out endpoint is used for writing. */ +if (serial->num_bulk_out <2 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + od =kmalloc (sizeof (struct omninet_data ),GFP_KERNEL );if (!od) { dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n",
drivers/usb/serial/option.c +7 -0
@@ -269,6 +269,8 @@ static void option_instat_callback(struct urb *urb);#define TELIT_PRODUCT_CC864_SINGLE 0x1006#define TELIT_PRODUCT_DE910_DUAL 0x1010#define TELIT_PRODUCT_UE910_V2 0x1012 +#define TELIT_PRODUCT_LE922_USBCFG1 0x1040 +#define TELIT_PRODUCT_LE922_USBCFG2 0x1041#define TELIT_PRODUCT_LE922_USBCFG0 0x1042#define TELIT_PRODUCT_LE922_USBCFG3 0x1043#define TELIT_PRODUCT_LE920 0x1200
@@ -1196,6 +1198,10 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG1), + .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG2), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3), .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
@@ -1957,6 +1963,7 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_6802, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD300, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d, 0xff, 0xff, 0xff) }, /* HP lt2523 (Novatel E371) */ { } /* Terminating entry */ };MODULE_DEVICE_TABLE (usb, option_ids);
drivers/usb/serial/oti6858.c +8 -0
@@ -347,9 +347,17 @@ static void send_data(struct work_struct *work)static int oti6858_startup (struct usb_serial *serial) {struct usb_serial_port *port = serial->port[0 ]; +unsigned char num_ports = serial->num_ports;struct oti6858_private *priv;int i; +if (serial->num_bulk_in < num_ports || + serial->num_bulk_out < num_ports || + serial->num_interrupt_in < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } +for (i =0 ; i < serial->num_ports; ++i) { priv =kzalloc (sizeof (struct oti6858_private ),GFP_KERNEL );if (!priv)
drivers/usb/serial/pl2303.c +9 -0
@@ -55,6 +55,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, + { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID2) }, { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID_UCSGT) },
@@ -185,10 +186,18 @@ static int pl2303_vendor_write(__u16 value, __u16 index,static int pl2303_startup (struct usb_serial *serial) {struct pl2303_private *priv; +unsigned char num_ports = serial->num_ports;enum pl2303_type type = type_0;unsigned char *buf;int i; +if (serial->num_bulk_in < num_ports || + serial->num_bulk_out < num_ports || + serial->num_interrupt_in < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + buf =kmalloc (10 ,GFP_KERNEL );if (buf ==NULL )return -ENOMEM ;
drivers/usb/serial/pl2303.h +1 -0
@@ -27,6 +27,7 @@#define ATEN_VENDOR_ID 0x0557#define ATEN_VENDOR_ID2 0x0547#define ATEN_PRODUCT_ID 0x2008 +#define ATEN_PRODUCT_ID2 0x2118#define IODATA_VENDOR_ID 0x04bb#define IODATA_PRODUCT_ID 0x0a03
drivers/usb/serial/spcp8x5.c +7 -0
@@ -176,6 +176,13 @@ static int spcp8x5_startup(struct usb_serial *serial)int i;enum spcp8x5_type type =SPCP825_007_TYPE ;u16 product =le16_to_cpu (serial->dev->descriptor.idProduct); +unsigned char num_ports = serial->num_ports; + +if (serial->num_bulk_in < num_ports || + serial->num_bulk_out < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + }if (product ==0x0201 ) type =SPCP825_007_TYPE ;
drivers/usb/serial/ti_usb_3410_5052.c +7 -0
@@ -438,6 +438,13 @@ static int ti_startup(struct usb_serial *serial) goto free_tdev; } +if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); + status = -ENODEV ; + goto free_tdev; + } +/* set up port structures */ for (i =0 ; i < serial->num_ports; ++i) { tport =kzalloc (sizeof (struct ti_port ),GFP_KERNEL );
fs/block_dev.c +1 -1
@@ -687,7 +687,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,return true;/* already a holder */ else if (bdev->bd_holder != NULL) return false; /* held by someone else */ - else if (bdev->bd_contains == bdev) + else if (whole == bdev) return true; /* is a whole device which isn't held */ else if (whole->bd_holder == bd_may_claim)
fs/btrfs/ioctl.c +4 -2
@@ -3276,6 +3276,10 @@ long btrfs_ioctl(struct file *file, unsigned int#ifdef CONFIG_COMPAT long btrfs_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { +/* +* These all access 32-bit values anyway so no further +* handling is necessary. +*/ switch (cmd) {case FS_IOC32_GETFLAGS : cmd =FS_IOC_GETFLAGS ;
@@ -3286,8 +3290,6 @@ long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case FS_IOC32_GETVERSION : cmd =FS_IOC_GETVERSION ;break ; -default : -return -ENOIOCTLCMD ; }return btrfs_ioctl (file, cmd, (unsigned long )compat_ptr (arg));
fs/btrfs/tree-log.c +1 -2
@@ -1415,12 +1415,11 @@ static noinline int find_dir_range(struct btrfs_root *root, next:/* check the next slot in the tree to see if it is a valid item */ nritems =btrfs_header_nritems (path->nodes[0 ]); + path->slots[0 ]++;if (path->slots[0 ] >= nritems) { ret =btrfs_next_leaf (root, path);if (ret) goto out; - }else { - path->slots[0 ]++; }btrfs_item_key_to_cpu (path->nodes[0 ], &key, path->slots[0 ]);
fs/ceph/mds_client.c +3 -1
@@ -238,7 +238,9 @@ static int parse_reply_info_extra(void **p, void *end, struct ceph_mds_reply_info_parsed *info, int features) { -if (info->head->op ==CEPH_MDS_OP_GETFILELOCK ) +u32 op =le32_to_cpu (info->head->op); + +if (op ==CEPH_MDS_OP_GETFILELOCK )return parse_reply_info_filelock (p, end, info, features);else return parse_reply_info_dir (p, end, info, features);
fs/ext4/inode.c +6 -0
@@ -3829,6 +3829,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)struct inode *inode;journal_t *journal =EXT4_SB (sb)->s_journal;long ret; +loff_t size;int block; inode =iget_locked (sb, ino);
@@ -3880,6 +3881,11 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) ei->i_file_acl |= ((__u64 )le16_to_cpu (raw_inode->i_file_acl_high)) <<32 ; inode->i_size =ext4_isize (raw_inode); +if ((size =i_size_read (inode)) <0 ) { +EXT4_ERROR_INODE (inode,"bad i_size value: %lld" , size); + ret = -EIO ; + goto bad_inode; + } ei->i_disksize = inode->i_size;#ifdef CONFIG_QUOTA ei->i_reserved_quota =0 ;
fs/ext4/mballoc.c +2 -2
@@ -652,7 +652,7 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,ext4_grpblk_t min;ext4_grpblk_t max;ext4_grpblk_t chunk; -unsigned short border; +unsigned int border;BUG_ON (len >EXT4_CLUSTERS_PER_GROUP (sb));
@@ -2134,7 +2134,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)struct ext4_buddy e4b;struct sg {struct ext4_group_info info; -ext4_grpblk_t counters[16 ]; +ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE +2 ]; } sg; group--;
fs/ext4/super.c +37 -27
39 lines not on this page · raw message
fs/notify/inode_mark.c +9 -37
46 lines not on this page · raw message
net/ipv4/igmp.c +41 -14
55 lines not on this page · raw message
net/ipv6/ip6_tunnel.c +33 -14
47 lines not on this page · raw message
net/ipv6/mcast.c +30 -20
50 lines not on this page · raw message
net/packet/af_packet.c +30 -15
45 lines not on this page · raw message
tools/perf/util/trace-event-scripting.c +4 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [PATCH 3.2 000/202] 3.2.87-rc2 review
In reply to Ben HutchingsQuoted 6 lines · Ben Hutchings
I've added three more patches to the queue for this release, which will be sent as replies to this message.
Responses should be made by Wed Mar 15 00:00:00 UTC 2017. Anything received after that time might be too late.
Still looks good.
Guenter