Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266AbdFEDon (ORCPT ); Sun, 4 Jun 2017 23:44:43 -0400 Received: from m12-11.163.com ([220.181.12.11]:46461 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225AbdFEDoi (ORCPT ); Sun, 4 Jun 2017 23:44:38 -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 read_nnode Date: Mon, 5 Jun 2017 11:46:00 +0800 Message-Id: <1496634360-8338-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: C8CowAC3xhJm0zRZGBMEJA--.42698S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfCw18tFy5uFy8Jry8AFb_yoWftFc_uF 48Cr15Ww40gr93tr45Cr4xGryqq3Wq9ry0ya1fAFya9Fy5JF15X39rArZxGFsruFsrZFW2 yrZ5Gw15ur1jkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbCJm5UUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiTgntelUCyNJ2pgAAsN Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 987 Lines: 34 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_get_pnode read_pnode 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..fabe2fd 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c @@ -1268,7 +1268,7 @@ static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) branch = &parent->nbranch[iip]; lnum = branch->lnum; offs = branch->offs; - pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS); + pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_ATOMIC); if (!pnode) return -ENOMEM; -- 1.7.9.5