crypto: drbg - simplify ordering of linked list in drbg_ctr_df
[firefly-linux-kernel-4.4.55.git] / crypto / drbg.c
index faaa2cefeeed64216739b9858daa76ac6e910e93..99fa8f89fb3e294ce6fafe023fa55408b0691a35 100644 (file)
@@ -516,13 +516,13 @@ static int drbg_ctr_df(struct drbg_state *drbg,
        S2.next = addtl;
 
        /*
-        * splice in addtl between S2 and S4 -- we place S4 at the end of the
-        * input data chain
+        * Splice in addtl between S2 and S4 -- we place S4 at the end
+        * of the input data chain. As this code is only triggered when
+        * addtl is not NULL, no NULL checks are necessary.
         */
        tempstr = addtl;
-       for (; NULL != tempstr; tempstr = tempstr->next)
-               if (NULL == tempstr->next)
-                       break;
+       while (tempstr->next)
+               tempstr = tempstr->next;
        tempstr->next = &S4;
 
        /* 10.4.2 step 9 */