在 2025/6/11 下午5:23, Herbert Xu 写道:
On Wed, May 28, 2025 at 02:59:41PM +0800, Qunqin Zhao wrote:
+       if (!rng_devices.is_init) {
+               ret = crypto_register_rng(&loongson_rng_alg);
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to register crypto(%d)\n", 
ret);
+                       return ret;
+               }
+               INIT_LIST_HEAD(&rng_devices.list);
+               mutex_init(&rng_devices.lock);
+               rng_devices.is_init = true;
+       }
This doesn't look right.  What stops two devices from both entering
this code path when is_init == false?

Will use __MUTEX_INITIALIZER  macro to statically initialize rng_devices. lock,

and then use this lock to stop two devices form both entering this code path.


Thanks,

Qunqin


Cheers,


Reply via email to