Skip to content

Commit

Permalink
macsec: check return value of skb_to_sgvec always
Browse files Browse the repository at this point in the history
Signed-off-by: Jason A. Donenfeld <[email protected]>
Cc: Sabrina Dubroca <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
zx2c4 authored and davem330 committed Jun 5, 2017
1 parent 89a5ea9 commit cda7ea6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/net/macsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,12 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
macsec_fill_iv(iv, secy->sci, pn);

sg_init_table(sg, ret);
skb_to_sgvec(skb, sg, 0, skb->len);
ret = skb_to_sgvec(skb, sg, 0, skb->len);
if (unlikely(ret < 0)) {
macsec_txsa_put(tx_sa);
kfree_skb(skb);
return ERR_PTR(ret);
}

if (tx_sc->encrypt) {
int len = skb->len - macsec_hdr_len(sci_present) -
Expand Down Expand Up @@ -947,7 +952,11 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
macsec_fill_iv(iv, sci, ntohl(hdr->packet_number));

sg_init_table(sg, ret);
skb_to_sgvec(skb, sg, 0, skb->len);
ret = skb_to_sgvec(skb, sg, 0, skb->len);
if (unlikely(ret < 0)) {
kfree_skb(skb);
return ERR_PTR(ret);
}

if (hdr->tci_an & MACSEC_TCI_E) {
/* confidentiality: ethernet + macsec header
Expand Down

0 comments on commit cda7ea6

Please sign in to comment.