Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753062AbdLLMtm (ORCPT ); Tue, 12 Dec 2017 07:49:42 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:37244 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753036AbdLLMth (ORCPT ); Tue, 12 Dec 2017 07:49:37 -0500 X-Google-Smtp-Source: ACJfBouguVmTd5cqxCFPNgwvavttzdccomL5/9vXRBbp9JHpUmmA6AF0C3BF4jEM2GZKKubVqmuzJw== From: Jia-Ju Bai To: martyn@welchs.me.uk, manohar.vanga@gmail.com, gregkh@linuxfoundation.org, elfring@users.sourceforge.net, martyn.welch@ge.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] vme: Fix a possible sleep-in-atomic bug in vme_tsi148 Date: Tue, 12 Dec 2017 20:51:53 +0800 Message-Id: <1513083113-27367-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 860 Lines: 30 The driver may sleep under a spinlock. The function call path is: tsi148_master_write \ tsi148_master_read (acquire the spinlock) vme_register_error_handler kmalloc(GFP_KERNEL) --> may sleep To fix it, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool(DSAC) and checked by my code review. Signed-off-by: Jia-Ju Bai --- drivers/vme/vme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index 8124622..92500f6 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -1290,7 +1290,7 @@ struct vme_error_handler *vme_register_error_handler( { struct vme_error_handler *handler; - handler = kmalloc(sizeof(*handler), GFP_KERNEL); + handler = kmalloc(sizeof(*handler), GFP_ATOMIC); if (!handler) return NULL; -- 1.7.9.5