IB/rxe: Remove buffer used for printing IP address
authorAndrew Boyer <andrew.boyer@dell.com>
Wed, 23 Nov 2016 17:39:17 +0000 (12:39 -0500)
committerDoug Ledford <dledford@redhat.com>
Mon, 12 Dec 2016 21:31:45 +0000 (16:31 -0500)
Avoid smashing the stack when an ICRC error occurs on an IPv6 network.

Signed-off-by: Andrew Boyer <andrew.boyer@dell.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/sw/rxe/rxe_recv.c

index 46f062842a9a28b0aecf3d193b63e3c88b9afca4..252b4d637d4569d7748650094256b1d1b1a9d19c 100644 (file)
@@ -391,16 +391,15 @@ int rxe_rcv(struct sk_buff *skb)
                             payload_size(pkt));
        calc_icrc = cpu_to_be32(~calc_icrc);
        if (unlikely(calc_icrc != pack_icrc)) {
-               char saddr[sizeof(struct in6_addr)];
-
                if (skb->protocol == htons(ETH_P_IPV6))
-                       sprintf(saddr, "%pI6", &ipv6_hdr(skb)->saddr);
+                       pr_warn_ratelimited("bad ICRC from %pI6c\n",
+                                           &ipv6_hdr(skb)->saddr);
                else if (skb->protocol == htons(ETH_P_IP))
-                       sprintf(saddr, "%pI4", &ip_hdr(skb)->saddr);
+                       pr_warn_ratelimited("bad ICRC from %pI4\n",
+                                           &ip_hdr(skb)->saddr);
                else
-                       sprintf(saddr, "unknown");
+                       pr_warn_ratelimited("bad ICRC from unknown\n");
 
-               pr_warn_ratelimited("bad ICRC from %s\n", saddr);
                goto drop;
        }