Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753197AbdLMOUJ (ORCPT ); Wed, 13 Dec 2017 09:20:09 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:46660 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752175AbdLMOUI (ORCPT ); Wed, 13 Dec 2017 09:20:08 -0500 X-Google-Smtp-Source: ACJfBosIG+jvGug9unSCYVlju7g7xKUxq5vBj1EKJ8pPzF4NJvAylcqLKyh87Q2kOnRCVL3xmHE2uQ== From: Jia-Ju Bai To: daniel.vetter@intel.com, jani.nikula@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, dh.herrmann@gmail.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] drm: Fix a possible sleep-in-atomic bug in show_leaks Date: Wed, 13 Dec 2017 22:22:23 +0800 Message-Id: <1513174943-18891-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: 848 Lines: 31 The driver may sleep under a spinlock. The function call path is: drm_vma_offset_manager_destroy (acquire the spinlock) drm_mm_takedown show_leaks 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/gpu/drm/drm_mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 61a1c8e..5b9965d 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -127,7 +127,7 @@ static void show_leaks(struct drm_mm *mm) unsigned long entries[STACKDEPTH]; char *buf; - buf = kmalloc(BUFSZ, GFP_KERNEL); + buf = kmalloc(BUFSZ, GFP_ATOMIC); if (!buf) return; -- 1.7.9.5