Received: by 10.213.65.68 with SMTP id h4csp3846354imn; Tue, 10 Apr 2018 05:42:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx49W+so0j85nt5o3q+tRd2j4CFqRzG0w7yXrDJD3YkFk0+Q+0RHJV/dODv0b0AePG+ywal9n X-Received: by 10.101.102.197 with SMTP id c5mr177967pgw.93.1523364121386; Tue, 10 Apr 2018 05:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523364121; cv=none; d=google.com; s=arc-20160816; b=nSrJQFlFH8l8C44evp1EyN3ruqF7LB+g5p0DzjSrjmiXhzV2ovt5cu4FHM2+hssg37 oITNOMEr2CDni8zcYYOf8cQSNwVgtK9L+J50vgXsgQqlhxCUATsrlECrhRDcqyqX5Zre roFsjfOdCMP79kPeyMAazxQaYsN7yZvDmgHZ9tww0uFRtMiXPYp3PKucv9W13GoDyQWR c/SPU1ww9uuxLFxjDy/7fI+nss8BT4R5JjLDYs/rSFMBzv7j2FJ8evmVHPkO2mguoAPy 2A2mxXSTyZ9/GgIHVWFgYXOXvkZqCYVhg7WEIsUbVjiTlrYjKfCusB9TjOkpq2y0LQ/N f2Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=0F3heZM1gkW4+FyAwJ5oi2J4jvnWrW7E2jqqe5DxhTA=; b=U2n132rHMkR5d4UT6sPfbveToxQjqAuyRz1+PD3uLS5bCgrqQhmOjGW3HRtizFqbwD v8PGy/t/jLeuIcxzs/9kHdqny/hqxeVrBlBDoa48rIvMguNIJLa2gh4wX23JphALpvb/ SqP/8vnoyQzf/z59KKQrwJyevhZqzoW1kc2MF1bT0xEedniO/gDIQwBjqe/oC5gnpQ+k 7W2h/Jl4LvzgtrowBRbijmj+XVI9YLOxeLHTK1+iX7c83DNLS0e4WYFmpDTlChQQmeap ZRaNffUSRRHjgyCIPi8xwyy1bgZE6oMSfEX/tVQYkSxjEeF2J9bd+0TFTPllNWs5symW +n6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jfad3gYj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d15-v6si2644711pls.232.2018.04.10.05.41.24; Tue, 10 Apr 2018 05:42:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jfad3gYj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753227AbeDJMiv (ORCPT + 99 others); Tue, 10 Apr 2018 08:38:51 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 1.9.1