Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751278AbdFEDgz (ORCPT ); Sun, 4 Jun 2017 23:36:55 -0400 Received: from m12-18.163.com ([220.181.12.18]:47893 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225AbdFEDgs (ORCPT ); Sun, 4 Jun 2017 23:36:48 -0400 From: Jia-Ju Bai To: richard@nod.at, dedekind1@gmail.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] ubifs: Fix a sleep-in-atomic bug in ubifs_read_nnode Date: Mon, 5 Jun 2017 11:38:36 +0800 Message-Id: <1496633916-32362-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: EsCowAAHdamp0TRZugddKQ--.24430S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfCw18tFy5uFy8Jry8AFb_yoWfCFb_uF 4IvryfXw48Wr93tr4YkrWfGr1DKa1vkryrta1fGFWa9F95JF15ua9rZrW5Grs8ZFW7CFy2 yrWkJw18u3WIkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU1nYFtUUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiYwztelaDtNX3pQAAse Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 943 Lines: 33 The driver may sleep under a spin lock, and the function call path is: ubifs_change_lp (acquire the lock by spin_lock) change_category ubifs_remove_from_cat remove_from_lpt_heap dbg_check_heap ubifs_lpt_lookup ubifs_read_nnode kzalloc(GFP_NOFS) --> may sleep To fix it, "GFP_NOFS" is replaced with "GFP_ATOMIC". Signed-off-by: Jia-Ju Bai --- fs/ubifs/lpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 9a51710..4247934c 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c @@ -1205,7 +1205,7 @@ int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) lnum = c->lpt_lnum; offs = c->lpt_offs; } - nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_NOFS); + nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_ATOMIC); if (!nnode) { err = -ENOMEM; goto out; -- 1.7.9.5