aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/pcrypt.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index 77425530ee11..de3078215fe6 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -26,6 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/notifier.h> 27#include <linux/notifier.h>
28#include <linux/kobject.h> 28#include <linux/kobject.h>
29#include <linux/cpu.h>
29#include <crypto/pcrypt.h> 30#include <crypto/pcrypt.h>
30 31
31struct padata_pcrypt { 32struct padata_pcrypt {
@@ -409,6 +410,7 @@ static int pcrypt_cpumask_change_notify(struct notifier_block *self,
409{ 410{
410 struct padata_pcrypt *pcrypt; 411 struct padata_pcrypt *pcrypt;
411 struct pcrypt_cpumask *new_mask, *old_mask; 412 struct pcrypt_cpumask *new_mask, *old_mask;
413 struct padata_cpumask *cpumask = (struct padata_cpumask *)data;
412 414
413 if (!(val & PADATA_CPU_SERIAL)) 415 if (!(val & PADATA_CPU_SERIAL))
414 return 0; 416 return 0;
@@ -424,7 +426,7 @@ static int pcrypt_cpumask_change_notify(struct notifier_block *self,
424 426
425 old_mask = pcrypt->cb_cpumask; 427 old_mask = pcrypt->cb_cpumask;
426 428
427 padata_get_cpumask(pcrypt->pinst, PADATA_CPU_SERIAL, new_mask->mask); 429 cpumask_copy(new_mask->mask, cpumask->cbcpu);
428 rcu_assign_pointer(pcrypt->cb_cpumask, new_mask); 430 rcu_assign_pointer(pcrypt->cb_cpumask, new_mask);
429 synchronize_rcu_bh(); 431 synchronize_rcu_bh();
430 432
@@ -451,6 +453,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
451 int ret = -ENOMEM; 453 int ret = -ENOMEM;
452 struct pcrypt_cpumask *mask; 454 struct pcrypt_cpumask *mask;
453 455
456 get_online_cpus();
457
454 pcrypt->wq = create_workqueue(name); 458 pcrypt->wq = create_workqueue(name);
455 if (!pcrypt->wq) 459 if (!pcrypt->wq)
456 goto err; 460 goto err;
@@ -467,7 +471,7 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
467 goto err_free_padata; 471 goto err_free_padata;
468 } 472 }
469 473
470 padata_get_cpumask(pcrypt->pinst, PADATA_CPU_SERIAL, mask->mask); 474 cpumask_and(mask->mask, cpu_possible_mask, cpu_active_mask);
471 rcu_assign_pointer(pcrypt->cb_cpumask, mask); 475 rcu_assign_pointer(pcrypt->cb_cpumask, mask);
472 476
473 pcrypt->nblock.notifier_call = pcrypt_cpumask_change_notify; 477 pcrypt->nblock.notifier_call = pcrypt_cpumask_change_notify;
@@ -479,7 +483,10 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
479 if (ret) 483 if (ret)
480 goto err_unregister_notifier; 484 goto err_unregister_notifier;
481 485
486 put_online_cpus();
487
482 return ret; 488 return ret;
489
483err_unregister_notifier: 490err_unregister_notifier:
484 padata_unregister_cpumask_notifier(pcrypt->pinst, &pcrypt->nblock); 491 padata_unregister_cpumask_notifier(pcrypt->pinst, &pcrypt->nblock);
485err_free_cpumask: 492err_free_cpumask:
@@ -490,6 +497,8 @@ err_free_padata:
490err_destroy_workqueue: 497err_destroy_workqueue:
491 destroy_workqueue(pcrypt->wq); 498 destroy_workqueue(pcrypt->wq);
492err: 499err:
500 put_online_cpus();
501
493 return ret; 502 return ret;
494} 503}
495 504