From patchwork Tue Apr 10 12:37:59 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: 10332943 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 475BD60365 for ; Tue, 10 Apr 2018 12:39:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38C7C285EA for ; Tue, 10 Apr 2018 12:39:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D127286FE; Tue, 10 Apr 2018 12:39:53 +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 CF102285EA for ; Tue, 10 Apr 2018 12:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbeDJMiV (ORCPT ); Tue, 10 Apr 2018 08:38:21 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:41310 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752584AbeDJMiS (ORCPT ); Tue, 10 Apr 2018 08:38:18 -0400 Received: by mail-pf0-f194.google.com with SMTP id a2so8188328pff.8; Tue, 10 Apr 2018 05:38:18 -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=Wq/1TGZ00nPBqHhB7NdeqSizRIjB8GzsuRhg26TOWOE=; b=G8raC8Wa7LNsLyLEfY5yyLaRJMPp4YnYQhjjK05fFgScaYW6dg/i33YtcMO1mVVe7e 0JYzlBvxY0eb/uiUaeNzkJT+PiEm12fpJherTbYkGHUfjSx654kG5yyGAQZ8OOkzRLqQ w9Z+pPT7keIxrzIvv85OVn7939uT3cAAa0nsk/JWZYUzz9BzDWOn0rTfmN1hYd/EGg0f YBEryTWLAnL0dmlwUg0vWXuC/DwegQqkslpbnp1Pz/KvM2GC16uL0BmVsI4YS5P9rZjV LFYfagR89X2f4SCxPZCtdXD1gYufxHFlQFb3vba56jKz7DwLwY8UZA3YBnA+u46Xvp4N dNvg== 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=Wq/1TGZ00nPBqHhB7NdeqSizRIjB8GzsuRhg26TOWOE=; b=s3B+pmDkmMMZ0wK0/LktYu7X7pg9J3e+h81/9z59GIIdQ3IeN7aUd1fJUTCevXC16f fGaTVzIZ2H0xLqw8HTaY8PsP24ghYs73osi6ThMXoeElYocgeXBL3yrbfsLScIPiDXzb aC52KWFG6AY5xtnKcyUuQsRwb9Cg6PPGgCaFpAsMSLA2jCwig+EbeeJXp83eBLd+kI/k pO+pMvkpXAX1M1IWac2nEBiO+Gj6UU0iscVNc8Ma+rmdfa14egWhBT+/pao/UNQrFOq8 iiUyQuuDCOx/N43BFxtwFwmXIjjlEvoh+st0z85xLKP60n/OgWIOFEg5MEcsk1TWgGnc +SqA== X-Gm-Message-State: ALQs6tCYOuD/b1MKx7KJI0fUQ/55KZWrr6grqMtEgOHb0cbl9cmFB/Lo ixNSz4+0DR7+YgQwwoGQrw8= X-Google-Smtp-Source: AIpwx4+RDvo4uuiGchV7/J7vEmosA5WpT3rJ8ro6IwA/XYrGjYhhQ3v2mq3CGtRVvhcjZJ//UhqhEQ== X-Received: by 10.101.69.198 with SMTP id m6mr186178pgr.244.1523363897906; Tue, 10 Apr 2018 05:38:17 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id g10sm6092149pgr.69.2018.04.10.05.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:38:17 -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 1/2] scsi: st: Replace GFP_ATOMIC with GFP_KERNEL in st_probe Date: Tue, 10 Apr 2018 20:37:59 +0800 Message-Id: <1523363879-31242-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 st_probe() is never called in atomic context. st_probe() is only set as ".probe" in struct scsi_driver. Despite never getting called from atomic context, st_probe() 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 94e402e..1da42f3 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -4290,7 +4290,7 @@ static int st_probe(struct device *dev) goto out_buffer_free; } - tpnt = kzalloc(sizeof(struct scsi_tape), GFP_ATOMIC); + tpnt = kzalloc(sizeof(struct scsi_tape), GFP_KERNEL); if (tpnt == NULL) { sdev_printk(KERN_ERR, SDp, "st: Can't allocate device descriptor.\n");