From patchwork Tue Apr 10 12:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10332941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B1286053B for ; Tue, 10 Apr 2018 12:39:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DDCE285EA for ; Tue, 10 Apr 2018 12:39:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62791286FE; Tue, 10 Apr 2018 12:39:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18DE8285EA for ; Tue, 10 Apr 2018 12:39:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074AbeDJMiu (ORCPT ); Tue, 10 Apr 2018 08:38:50 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34827 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753198AbeDJMis (ORCPT ); Tue, 10 Apr 2018 08:38:48 -0400 Received: by mail-pf0-f195.google.com with SMTP id u86so8195488pfd.2; Tue, 10 Apr 2018 05:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0F3heZM1gkW4+FyAwJ5oi2J4jvnWrW7E2jqqe5DxhTA=; b=Jfad3gYj1NU9bj/fDa7A83mtkeMCkb0O5e3waawRCXRFntt5yLfFVRgBsHxyn013uP G6z5nrnGKSRTc005y1ep7w+0rvzjuVHGrjZpZdSXzYGxw5PFRaSgy0HS21FyFpiEMgiq ki/NRGjqotcJeVZBIehfHGpmeMrKWjPfufY9h/Rh0h3P7D3HOZRPOJ0b7igM0TIV8fwq SmOSYQLocXZxa7XAxSokVNl946US8/lttHDIhBxGE9LUI5nFakhRk9hBEa2rzSgY47Ht TwPAKFICjy9s4wcn51s6RmxNAs2gYRDSRTWQ516pPclMlOEwr+RfKC0wLVph7TOlBJa1 SUZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0F3heZM1gkW4+FyAwJ5oi2J4jvnWrW7E2jqqe5DxhTA=; b=fmJ+hdZdBadoNQPBTHWnc08hC1duA2f5dAce9JJbgntdX0soYTbtZL2T8NB4RU33uD eJBLVGEt8wZX7UMZLJBgEWOY+wMqg1Lahz+DJAz9aoFmyQmURCOh8FGFClJL7eW+KYzS /n2HyEmt09nxOs0gjvwxW68RXcKE3YuiO7xZfEsRG4Q+/cxqTEMEMyM2JVlBjOq9rVaq 9zBr73WKnKqApLJ6vew0edo0f+nM22dWbxDeQgIWkNg6dQ5asrNhHtUK7dnEwQt9LKHO fZRWVncktU7xFo6d+8IYuNw65JfwVKkq7f04hQStKGyLeJZpKEzSR5OAgXIi/z2GeFkm 4q3g== X-Gm-Message-State: ALQs6tB7uywIyf9SpFuaE5HC0WmiWQJyTYzAIuh2ZbtId1S+ckCCuKSX QNLa4xRf5yhjZyHG0Av5SYM= X-Google-Smtp-Source: AIpwx4+2I3UT43Gn/69o8SmQlA0naAefoCv/AsJi1LHn/aVAlkssoV5uOJW9baPlmBGgvCV6SEFS2A== X-Received: by 10.98.220.86 with SMTP id t83mr235794pfg.60.1523363928138; Tue, 10 Apr 2018 05:38:48 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id x128sm5060287pgb.31.2018.04.10.05.38.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:38:47 -0700 (PDT) From: Jia-Ju Bai To: Kai.Makisara@kolumbus.fi, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/2] scsi: st: Replace GFP_ATOMIC with GFP_KERNEL in new_tape_buffer Date: Tue, 10 Apr 2018 20:38:42 +0800 Message-Id: <1523363922-31330-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP new_tape_buffer() is never called in atomic context. new_tape_buffer() is only called by st_probe(), which is only set as ".probe" in struct scsi_driver. Despite never getting called from atomic context, new_tape_buffer() calls kzalloc() with GFP_ATOMIC, which does not sleep for allocation. GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL, which can sleep and improve the possibility of sucessful allocation. This is found by a static analysis tool named DCNS written by myself. And I also manually check it. Signed-off-by: Jia-Ju Bai --- drivers/scsi/st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 94e402e..b987f6d 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -3878,7 +3878,7 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg) { struct st_buffer *tb; - tb = kzalloc(sizeof(struct st_buffer), GFP_ATOMIC); + tb = kzalloc(sizeof(struct st_buffer), GFP_KERNEL); if (!tb) { printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n"); return NULL; @@ -3889,7 +3889,7 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg) tb->buffer_size = 0; tb->reserved_pages = kzalloc(max_sg * sizeof(struct page *), - GFP_ATOMIC); + GFP_KERNEL); if (!tb->reserved_pages) { kfree(tb); return NULL;