X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=crypto%2Fcryptomgr.c;h=e5fb7cca5107d742ccd999bc87eaaf024a204f07;hb=d3f9882cca84a7cb67a19bbc597356b49896b8c2;hp=7a3df9b4121881a65bd723ee7ef883baaec0e80f;hpb=ebc610e5bc76df073221e64e86c3f7533a09ea40;p=powerpc.git diff --git a/crypto/cryptomgr.c b/crypto/cryptomgr.c index 7a3df9b412..e5fb7cca51 100644 --- a/crypto/cryptomgr.c +++ b/crypto/cryptomgr.c @@ -14,18 +14,16 @@ #include #include #include +#include #include #include #include #include #include -#include #include "internal.h" struct cryptomgr_param { - struct work_struct work; - struct rtattr *tb[CRYPTOA_MAX]; struct { @@ -45,10 +43,9 @@ struct cryptomgr_param { char template[CRYPTO_MAX_ALG_NAME]; }; -static void cryptomgr_probe(struct work_struct *work) +static int cryptomgr_probe(void *data) { - struct cryptomgr_param *param = - container_of(work, struct cryptomgr_param, work); + struct cryptomgr_param *param = data; struct crypto_template *tmpl; struct crypto_instance *inst; int err; @@ -72,7 +69,7 @@ static void cryptomgr_probe(struct work_struct *work) out: kfree(param); - return; + module_put_and_exit(0); err: crypto_larval_error(param->larval.name, param->type.data.type, @@ -82,14 +79,18 @@ err: static int cryptomgr_schedule_probe(struct crypto_larval *larval) { + struct task_struct *thread; struct cryptomgr_param *param; const char *name = larval->alg.cra_name; const char *p; unsigned int len; + if (!try_module_get(THIS_MODULE)) + goto err; + param = kzalloc(sizeof(*param), GFP_KERNEL); if (!param) - goto err; + goto err_put_module; for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++) ; @@ -101,11 +102,18 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval) memcpy(param->template, name, len); name = p + 1; - for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++) - ; + len = 0; + for (p = name; *p; p++) { + for (; isalnum(*p) || *p == '-' || *p == '_' || *p == '('; p++) + ; - len = p - name; - if (!len || *p != ')' || p[1]) + if (*p != ')') + goto err_free_param; + + len = p - name; + } + + if (!len || name[len + 1]) goto err_free_param; param->type.attr.rta_len = sizeof(param->type); @@ -121,13 +129,16 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval) memcpy(param->larval.name, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME); - INIT_WORK(¶m->work, cryptomgr_probe); - schedule_work(¶m->work); + thread = kthread_run(cryptomgr_probe, param, "cryptomgr"); + if (IS_ERR(thread)) + goto err_free_param; return NOTIFY_STOP; err_free_param: kfree(param); +err_put_module: + module_put(THIS_MODULE); err: return NOTIFY_OK; }