diff mbox

hwrng: correct error check of kthread_run call

Message ID 1437736410-39227-1-git-send-email-schwidefsky@de.ibm.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Martin Schwidefsky July 24, 2015, 11:13 a.m. UTC
The kthread_run() function can return two different error values
but the hwrng core only checks for -ENOMEM. If the other error
value -EINTR is returned it is assigned to hwrng_fill and later
used on a kthread_stop() call which naturally crashes.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
 drivers/char/hw_random/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu July 28, 2015, 7:03 a.m. UTC | #1
On Fri, Jul 24, 2015 at 01:13:30PM +0200, Martin Schwidefsky wrote:
> The kthread_run() function can return two different error values
> but the hwrng core only checks for -ENOMEM. If the other error
> value -EINTR is returned it is assigned to hwrng_fill and later
> used on a kthread_stop() call which naturally crashes.
> 
> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

Applied to crypto.
diff mbox

Patch

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index da8faf7..5643b65 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -429,7 +429,7 @@  static int hwrng_fillfn(void *unused)
 static void start_khwrngd(void)
 {
 	hwrng_fill = kthread_run(hwrng_fillfn, NULL, "hwrng");
-	if (hwrng_fill == ERR_PTR(-ENOMEM)) {
+	if (IS_ERR(hwrng_fill)) {
 		pr_err("hwrng_fill thread creation failed");
 		hwrng_fill = NULL;
 	}