Hi:

While adding crypto_remove_spawns I noticed that the loop isn't quite
right.

[CRYPTO] api: Fix potential cra_users leak in crypto_remove_spawns

When we walk the spawns list we keep adding the cra_users list of each
entry that we process to the end of the list.  If the entry we process
happens to be the last of the spawns list, the newly added entries will
not be processed.  Thie patch fixes it by changing n if the it is the
last entry of spawns.

Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/crypto/api.c b/crypto/api.c
index fe15f5c..23dd53d 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -494,8 +494,14 @@ static void crypto_remove_spawns(struct 
                crypto_notify(CRYPTO_MSG_ALG_UNREGISTER, &inst->alg);
                list_move(&inst->alg.cra_list, list);
                hlist_del(&inst->list);
-               list_splice(&inst->alg.cra_users, spawns->prev);
                inst->alg.cra_destroy = crypto_destroy_instance;
+
+               if (!list_empty(&inst->alg.cra_users)) {
+                       if (&n->list == spawns)
+                               n = list_entry(inst->alg.cra_users.next,
+                                              typeof(*n), list);
+                       __list_splice(&inst->alg.cra_users, spawns->prev);
+               }
        }
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to