Skip to content

Commit fce471e

Browse files
committed
Merge branch 'iucv-fixes'
Julian Wiedmann says: ==================== net/iucv: fixes 2018-09-05 please apply three straight-forward fixes for iucv. One that prevents leaking the skb on malformed inbound packets, one to fix the error handling on transmit error, and one to get rid of a compile warning. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ee28bb5 + b7f4156 commit fce471e

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

net/iucv/af_iucv.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,28 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
351351
memcpy(&phs_hdr->iucv_hdr, imsg, sizeof(struct iucv_message));
352352

353353
skb->dev = iucv->hs_dev;
354-
if (!skb->dev)
355-
return -ENODEV;
356-
if (!(skb->dev->flags & IFF_UP) || !netif_carrier_ok(skb->dev))
357-
return -ENETDOWN;
354+
if (!skb->dev) {
355+
err = -ENODEV;
356+
goto err_free;
357+
}
358+
if (!(skb->dev->flags & IFF_UP) || !netif_carrier_ok(skb->dev)) {
359+
err = -ENETDOWN;
360+
goto err_free;
361+
}
358362
if (skb->len > skb->dev->mtu) {
359-
if (sock->sk_type == SOCK_SEQPACKET)
360-
return -EMSGSIZE;
361-
else
362-
skb_trim(skb, skb->dev->mtu);
363+
if (sock->sk_type == SOCK_SEQPACKET) {
364+
err = -EMSGSIZE;
365+
goto err_free;
366+
}
367+
skb_trim(skb, skb->dev->mtu);
363368
}
364369
skb->protocol = cpu_to_be16(ETH_P_AF_IUCV);
365370
nskb = skb_clone(skb, GFP_ATOMIC);
366-
if (!nskb)
367-
return -ENOMEM;
371+
if (!nskb) {
372+
err = -ENOMEM;
373+
goto err_free;
374+
}
375+
368376
skb_queue_tail(&iucv->send_skb_q, nskb);
369377
err = dev_queue_xmit(skb);
370378
if (net_xmit_eval(err)) {
@@ -375,6 +383,10 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
375383
WARN_ON(atomic_read(&iucv->msg_recv) < 0);
376384
}
377385
return net_xmit_eval(err);
386+
387+
err_free:
388+
kfree_skb(skb);
389+
return err;
378390
}
379391

380392
static struct sock *__iucv_get_sock_by_name(char *nm)
@@ -1167,7 +1179,7 @@ static int iucv_sock_sendmsg(struct socket *sock, struct msghdr *msg,
11671179
err = afiucv_hs_send(&txmsg, sk, skb, 0);
11681180
if (err) {
11691181
atomic_dec(&iucv->msg_sent);
1170-
goto fail;
1182+
goto out;
11711183
}
11721184
} else { /* Classic VM IUCV transport */
11731185
skb_queue_tail(&iucv->send_skb_q, skb);
@@ -2155,8 +2167,8 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
21552167
struct sock *sk;
21562168
struct iucv_sock *iucv;
21572169
struct af_iucv_trans_hdr *trans_hdr;
2170+
int err = NET_RX_SUCCESS;
21582171
char nullstring[8];
2159-
int err = 0;
21602172

21612173
if (skb->len < (ETH_HLEN + sizeof(struct af_iucv_trans_hdr))) {
21622174
WARN_ONCE(1, "AF_IUCV too short skb, len=%d, min=%d",
@@ -2254,7 +2266,7 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
22542266
err = afiucv_hs_callback_rx(sk, skb);
22552267
break;
22562268
default:
2257-
;
2269+
kfree_skb(skb);
22582270
}
22592271

22602272
return err;

net/iucv/iucv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ static void iucv_pm_complete(struct device *dev)
18741874
* Returns 0 if there are still iucv pathes defined
18751875
* 1 if there are no iucv pathes defined
18761876
*/
1877-
int iucv_path_table_empty(void)
1877+
static int iucv_path_table_empty(void)
18781878
{
18791879
int i;
18801880

0 commit comments

Comments
 (0)