patch-2.1.89 linux/net/ipx/af_ipx.c

Next file: linux/net/netlink/af_netlink.c
Previous file: linux/net/ipv6/udp.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.88/linux/net/ipx/af_ipx.c linux/net/ipx/af_ipx.c
@@ -998,7 +998,8 @@
 		return -EPROTONOSUPPORT;
 
 	dev=dev_get(idef->ipx_device);
-	if(dev==NULL) return -ENODEV;
+	if (dev==NULL)
+		return -ENODEV;
 
 	intrfc = ipxitf_find_using_phys(dev, dlink_type);
 	if (intrfc != NULL) {
@@ -1107,9 +1108,9 @@
 			sipx->sipx_family=AF_IPX;
 			sipx->sipx_network=ipxif->if_netnum;
 			memcpy(sipx->sipx_node, ipxif->if_node, sizeof(sipx->sipx_node));
-			err = copy_to_user(arg,&ifr,sizeof(ifr));
-			if (err)
-				return -EFAULT;
+			err = -EFAULT;
+			if (!copy_to_user(arg, &ifr, sizeof(ifr)))
+				err = 0;
 			return err;
 		}
 		case SIOCAIPXITFCRT: 
@@ -2134,32 +2135,28 @@
 	struct sock *sk=sock->sk;
 	struct sockaddr_ipx *sipx=(struct sockaddr_ipx *)msg->msg_name;
 	struct ipxhdr *ipx = NULL;
-	int copied = 0;
-	int truesize;
 	struct sk_buff *skb;
-	int err;
+	int copied, err;
 
 	if (sk->zapped)
 		return -ENOTCONN;
 
 	skb=skb_recv_datagram(sk,flags&~MSG_DONTWAIT,flags&MSG_DONTWAIT,&err);
-	if(skb==NULL)
-		return err;
+	if (!skb)
+		goto out;
 
 	ipx = skb->nh.ipxh;
-	truesize=ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
-	
-	copied = truesize;
+	copied = ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
 	if(copied > size)
 	{
 		copied=size;
 		msg->msg_flags|=MSG_TRUNC;
 	}
 
-	err = skb_copy_datagram_iovec(skb,sizeof(struct ipxhdr),msg->msg_iov,copied);
-	
+	err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
+					copied);
 	if (err)
-		return err;
+		goto out_free;
 
 	msg->msg_namelen = sizeof(*sipx);
 
@@ -2171,9 +2168,12 @@
 		sipx->sipx_network=ipx->ipx_source.net;
 		sipx->sipx_type = ipx->ipx_type;
 	}
-	skb_free_datagram(sk, skb);
+	err = copied;
 
-	return(copied);
+out_free:
+	skb_free_datagram(sk, skb);
+out:
+	return err;
 }
 
 /*
@@ -2228,11 +2228,12 @@
 			{
 				if(sk->stamp.tv_sec==0)
 					return -ENOENT;
-				ret = copy_to_user((void *)arg,&sk->stamp,sizeof(struct timeval));
-				if (ret)
-					ret = -EFAULT;
+				ret = -EFAULT;
+				if (!copy_to_user((void *)arg, &sk->stamp,
+						sizeof(struct timeval)))
+					ret = 0;
 			}
-			return 0;
+			return ret;
 		}
 		case SIOCGIFDSTADDR:
 		case SIOCSIFDSTADDR:

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov