From: Karl Hiramoto Subject: [PATCH] ixp4xx_crypto: fix possible sleep while atomic Date: Tue, 12 Jan 2010 16:06:05 +0100 Message-ID: <1263308765-17427-1-git-send-email-karl@hiramoto.org> Cc: linux-crypto@vger.kernel.org, Karl Hiramoto To: chohnstaedt@innominate.com Return-path: Received: from hapkido.dreamhost.com ([66.33.216.122]:57395 "EHLO hapkido.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448Ab0ALPIM (ORCPT ); Tue, 12 Jan 2010 10:08:12 -0500 Received: from homiemail-a27.g.dreamhost.com (caiajhbdcahe.dreamhost.com [208.97.132.74]) by hapkido.dreamhost.com (Postfix) with ESMTP id 8311C17828E for ; Tue, 12 Jan 2010 07:07:25 -0800 (PST) Sender: linux-crypto-owner@vger.kernel.org List-ID: use GFP_ATOMIC to allocate crypt_virt BUG: sleeping function called from invalid context at mm/page_alloc.c:1470 in_atomic(): 0, irqs_disabled(): 128, pid: 1376, name: cryptomgr_test 1 lock held by cryptomgr_test/1376: #0: (&desc_lock){....}, at: [] get_crypt_desc+0x14/0xe8 [ixp4xx_crypto] [] (dump_stack+0x0/0x14) from [] (__might_sleep+0xcc/0xe8) [] (__might_sleep+0x0/0xe8) from [] (__alloc_pages_internal+0xa4/0x430) r4:000000d0 [] (__alloc_pages_internal+0x0/0x430) from [] (__dma_alloc+0x180/0x3e8) [] (__dma_alloc+0x0/0x3e8) from [] (dma_alloc_coherent+0x58/0x64) [] (dma_alloc_coherent+0x0/0x64) from [] (get_crypt_desc+0x3c/0xe8 [ixp4xx_crypto]) r7:c3bc3ce8 r6:c3bc3cc0 r5:20000013 r4:bf14a81c [] (get_crypt_desc+0x0/0xe8 [ixp4xx_crypto]) from [] (ablk_perform+0x68/0x248 [ixp4xx_crypto]) r7:c3bc3ce8 r6:c3bc3cc0 r5:c2cefc2c r4:00000000 [] (ablk_perform+0x0/0x248 [ixp4xx_crypto]) from [] (ablk_encrypt+0x14/0x18 [ixp4xx_crypto]) [] (ablk_encrypt+0x0/0x18 [ixp4xx_crypto]) from [] (test_skcipher+0x1bc/0x668) [] (test_skcipher+0x0/0x668) from [] (alg_test_skcipher+0x60/0xa0) [] (alg_test_skcipher+0x0/0xa0) from [] (alg_test+0x128/0x160) r7:00000000 r6:00000286 r5:c39ddd80 r4:c39dddc0 [] (alg_test+0x0/0x160) from [] (cryptomgr_test+0x38/0x58) [] (cryptomgr_test+0x0/0x58) from [] (kthread+0x58/0x90) r4:c2e38000 [] (kthread+0x0/0x90) from [] (do_exit+0x0/0x6d0) r6:00000000 r5:00000000 r4:00000000 Note this is somewhat hard to reproduce, but can be reproduced under memory pressure when you first initialize ixp4xx_crypto. Signed-off-by: Karl Hiramoto --- drivers/crypto/ixp4xx_crypto.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index 6c6656d..564d68f 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c @@ -246,7 +246,7 @@ static int setup_crypt_desc(void) BUILD_BUG_ON(sizeof(struct crypt_ctl) != 64); crypt_virt = dma_alloc_coherent(dev, NPE_QLEN * sizeof(struct crypt_ctl), - &crypt_phys, GFP_KERNEL); + &crypt_phys, GFP_ATOMIC); if (!crypt_virt) return -ENOMEM; memset(crypt_virt, 0, NPE_QLEN * sizeof(struct crypt_ctl)); -- 1.6.4.4