OSDN Git Service

rds: debug: fix null check on static array
authorPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Wed, 6 Dec 2017 01:47:04 +0000 (10:47 +0900)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Dec 2017 20:02:48 +0000 (15:02 -0500)
t_name cannot be NULL since it is an array field of a struct.
Replacing null check on static array with string length check using
strnlen()

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/connection.c

index 9efc82c..6492c0b 100644 (file)
@@ -230,8 +230,8 @@ static struct rds_connection *__rds_conn_create(struct net *net,
 
        rdsdebug("allocated conn %p for %pI4 -> %pI4 over %s %s\n",
          conn, &laddr, &faddr,
-         trans->t_name ? trans->t_name : "[unknown]",
-         is_outgoing ? "(outgoing)" : "");
+         strnlen(trans->t_name, sizeof(trans->t_name)) ? trans->t_name :
+         "[unknown]", is_outgoing ? "(outgoing)" : "");
 
        /*
         * Since we ran without holding the conn lock, someone could