frag = kmalloc(sizeof(struct zd1201_frag*), GFP_ATOMIC); 
frag = kmalloc(sizeof(*frag), GFP_ATOMIC); 
static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs){	struct zd1201 *zd = urb->context;	int free = 0;	unsigned char *data = urb->transfer_buffer;	struct sk_buff *skb;	unsigned char type;	if (!zd) {		free = 1;		goto exit;	}	switch(urb->status) {		case -EILSEQ:		case -ENODEV:		case -ETIMEDOUT:		case -ENOENT:		case -EPIPE:		case -EOVERFLOW:		case -ESHUTDOWN:			dev_warn(&zd->usb->dev, "%s: rx urb failed: %d\n",			    zd->dev->name, urb->status);			free = 1;			goto exit;	}		if (urb->status != 0 || urb->actual_length == 0)		goto resubmit;	type = data[0];	if (type == ZD1201_PACKET_EVENTSTAT || type == ZD1201_PACKET_RESOURCE) {		memcpy(zd->rxdata, data, urb->actual_length);		zd->rxlen = urb->actual_length;		zd->rxdatas = 1;		wake_up(&zd->rxdataq);	}	/* Info frame */	if (type == ZD1201_PACKET_INQUIRE) {		int i = 0;		unsigned short infotype, framelen, copylen;		framelen = le16_to_cpu(*(__le16*)&data[4]);		infotype = le16_to_cpu(*(__le16*)&data[6]);		if (infotype == ZD1201_INF_LINKSTATUS) {			short linkstatus;			linkstatus = le16_to_cpu(*(__le16*)&data[8]);			switch(linkstatus) {				case 1:					netif_carrier_on(zd->dev);					break;				case 2:					netif_carrier_off(zd->dev);					break;				case 3:					netif_carrier_off(zd->dev);					break;				case 4:					netif_carrier_on(zd->dev);					break;				default:					netif_carrier_off(zd->dev);			}			goto resubmit;		}		if (infotype == ZD1201_INF_ASSOCSTATUS) {			short status = le16_to_cpu(*(__le16*)(data+8));			int event;			union iwreq_data wrqu;			switch (status) {				case ZD1201_ASSOCSTATUS_STAASSOC:				case ZD1201_ASSOCSTATUS_REASSOC:					event = IWEVREGISTERED;					break;				case ZD1201_ASSOCSTATUS_DISASSOC:				case ZD1201_ASSOCSTATUS_ASSOCFAIL:				case ZD1201_ASSOCSTATUS_AUTHFAIL:				default:					event = IWEVEXPIRED;			}			memcpy(wrqu.addr.sa_data, data+10, ETH_ALEN);			wrqu.addr.sa_family = ARPHRD_ETHER;			/* Send event to user space */			wireless_send_event(zd->dev, event, &wrqu, NULL);			goto resubmit;		}		if (infotype == ZD1201_INF_AUTHREQ) {			union iwreq_data wrqu;			memcpy(wrqu.addr.sa_data, data+8, ETH_ALEN);			wrqu.addr.sa_family = ARPHRD_ETHER;			/* There isn't a event that trully fits this request.			   We assume that userspace will be smart enough to			   see a new station being expired and sends back a			   authstation ioctl to authorize it. */			wireless_send_event(zd->dev, IWEVEXPIRED, &wrqu, NULL);			goto resubmit;		}		/* Other infotypes are handled outside this handler */		zd->rxlen = 0;		while (i < urb->actual_length) {			copylen = le16_to_cpu(*(__le16*)&data[i+2]);			/* Sanity check, sometimes we get junk */			if (copylen+zd->rxlen > sizeof(zd->rxdata))				break;			memcpy(zd->rxdata+zd->rxlen, data+i+4, copylen);			zd->rxlen += copylen;			i += 64;		}		if (i >= urb->actual_length) {			zd->rxdatas = 1;			wake_up(&zd->rxdataq);		}		goto  resubmit;	}	/* Actual data */	if (data[urb->actual_length-1] == ZD1201_PACKET_RXDATA) {		int datalen = urb->actual_length-1;		unsigned short len, fc, seq;		struct hlist_node *node;		len = ntohs(*(__be16 *)&data[datalen-2]);		if (len>datalen)			len=datalen;		fc = le16_to_cpu(*(__le16 *)&data[datalen-16]);		seq = le16_to_cpu(*(__le16 *)&data[datalen-24]);		if(zd->monitor) {			if (datalen < 24)				goto resubmit;			if (!(skb = dev_alloc_skb(datalen+24)))				goto resubmit;						memcpy(skb_put(skb, 2), &data[datalen-16], 2);			memcpy(skb_put(skb, 2), &data[datalen-2], 2);			memcpy(skb_put(skb, 6), &data[datalen-14], 6);			memcpy(skb_put(skb, 6), &data[datalen-22], 6);			memcpy(skb_put(skb, 6), &data[datalen-8], 6);			memcpy(skb_put(skb, 2), &data[datalen-24], 2);			memcpy(skb_put(skb, len), data, len);			skb->dev = zd->dev;			skb->dev->last_rx = jiffies;			skb->protocol = eth_type_trans(skb, zd->dev);			zd->stats.rx_packets++;			zd->stats.rx_bytes += skb->len;			netif_rx(skb);			goto resubmit;		}					if ((seq & IEEE802_11_SCTL_FRAG) ||		    (fc & IEEE802_11_FCTL_MOREFRAGS)) {			struct zd1201_frag *frag = NULL;			char *ptr;			if (datalen<14)				goto resubmit;			if ((seq & IEEE802_11_SCTL_FRAG) == 0) {				frag = kmalloc(sizeof(struct zd1201_frag*),				    GFP_ATOMIC);				if (!frag)					goto resubmit;				skb = dev_alloc_skb(IEEE802_11_DATA_LEN +14+2);				if (!skb) {					kfree(frag);					goto resubmit;				}				frag->skb = skb;				frag->seq = seq & IEEE802_11_SCTL_SEQ;				skb_reserve(skb, 2);				memcpy(skb_put(skb, 12), &data[datalen-14], 12);				memcpy(skb_put(skb, 2), &data[6], 2);				memcpy(skb_put(skb, len), data+8, len);				hlist_add_head(&frag->fnode, &zd->fraglist);				goto resubmit;			}			hlist_for_each_entry(frag, node, &zd->fraglist, fnode)				if(frag->seq == (seq&IEEE802_11_SCTL_SEQ))					break;			if (!frag)				goto resubmit;			skb = frag->skb;			ptr = skb_put(skb, len);			if (ptr)				memcpy(ptr, data+8, len);			if (fc & IEEE802_11_FCTL_MOREFRAGS)				goto resubmit;			hlist_del_init(&frag->fnode);			kfree(frag);			/* Fallthrough */		} else {			if (datalen<14)				goto resubmit;			skb = dev_alloc_skb(len + 14 + 2);			if (!skb)				goto resubmit;			skb_reserve(skb, 2);			memcpy(skb_put(skb, 12), &data[datalen-14], 12);			memcpy(skb_put(skb, 2), &data[6], 2);			memcpy(skb_put(skb, len), data+8, len);		}		skb->dev = zd->dev;		skb->dev->last_rx = jiffies;		skb->protocol = eth_type_trans(skb, zd->dev);		zd->stats.rx_packets++;		zd->stats.rx_bytes += skb->len;		netif_rx(skb);	}resubmit:	memset(data, 0, ZD1201_RXSIZE);	urb->status = 0;	urb->dev = zd->usb;	if(usb_submit_urb(urb, GFP_ATOMIC))		free = 1;exit:	if (free) {		zd->rxlen = 0;		zd->rxdatas = 1;		wake_up(&zd->rxdataq);		kfree(urb->transfer_buffer);	}	return;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/81065e2f415af6c028eac13f481fb9e60a0b487b/zd1201.c/clean/drivers/usb/net/zd1201.c