Received: by 10.213.65.68 with SMTP id h4csp2728699imn; Mon, 9 Apr 2018 08:07:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+qcWfoccGLNUbik60jxrDGzD7ejKz9UTsyrabxbPh3AjzFdDSd7v5DCYMLt47yb60IAST6 X-Received: by 2002:a17:902:32a2:: with SMTP id z31-v6mr40257563plb.41.1523286476791; Mon, 09 Apr 2018 08:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523286476; cv=none; d=google.com; s=arc-20160816; b=F169ruSJhWbAepcFW0rSYrc2qVMnL7kffs1SJ2m6r9+7VbTr62UIteSc1fZ7yCn1xg HvJ339MobLm1SbA7Nnf6jdGuSvQhb4hquqW7aKFq0JL5rkcR9fg2BU6aMU1Hv4uJvDoq q9IhOM2RAnSr4lKMhJ4RLnZMTAGnIAFKBgtcTx4s/fHFDM9hbtRKLnlhJVwSrXLW9dzr E8u2abxTzw3esxMR0yhB3rbvG4FCl1O6qbvUdXFuoXiBM6A+bg/Od/+bxYvKfWHcJM8B u1ibi7AdxOMatTTbXvs+jz3bQDBh2RCuQOK2wpjVft3rd/1IfXeDALzhAAP7y1nEh7zg wAnA== 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=BXD7mZaw6n7Frr/mGvCeKqk3NudOAoZm/oyIbjL/Fsg=; b=jyZ91gf1Vufqh7OHN67QY5Nkn9oNN++xbcJUvlySBTSAOwF2SzHt2pNSfy8o45CPQY xbn6UrvCV2WcSYlESUfssw5cK2KTzPjh53zP59SoqnN4kQMJowjWYoZ3/JktQ9ffpmAL pPzmv/AeKBjFbTHOLfzvCXZtPDr4jNs+zs+R8LjAQ5KXKuI8hD/myTO1RyZLDLX+xClW CPg7bOGp4KZkaxGB9KepeQrQNo1s6A+A8VHmIMpGe0R77Ug6EjbKjMNYK9UreK8Z4uHJ qymmE34RmioH6KY1ZFA9Yk1AyQ5L3AWmO+hPrd5TvksWvqXls6mnEvHVgaQyL/4/iz+S z76A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HdwMeUCu; 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 s15-v6si458531plj.701.2018.04.09.08.07.18; Mon, 09 Apr 2018 08:07:56 -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=HdwMeUCu; 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 S1753074AbeDIPEC (ORCPT + 99 others); Mon, 9 Apr 2018 11:04:02 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:34915 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753047AbeDIPEB (ORCPT ); Mon, 9 Apr 2018 11:04:01 -0400 Received: by mail-pl0-f68.google.com with SMTP id 61-v6so5326952plb.2 for ; Mon, 09 Apr 2018 08:04:01 -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=BXD7mZaw6n7Frr/mGvCeKqk3NudOAoZm/oyIbjL/Fsg=; b=HdwMeUCupws5qnijqVMK/vERPi5wG8jJhhbmsiTn+ZRUGJ1gd52tWuqdc0lCMR7NJ9 dZxKgHQoRyn/cuf0F1nrmMprTYpPKSh2VdbJC5tC/jrp+xTrD89Eqit+lgwAes0ZeHJZ 05ZPrCmPKJN7qs+5/WPY4P0OIjm7pAUvTvaMMLCqlJhgX8DMSUseeOREf6IQLKu1Wjks h9gloHURumFCFlv//NMwpfLDFcepEy/H3w7z5QpSKFkge85wpYUAtxc3ImyOIgy0fKhM 4f24T6oJPvr0mduI6inLt8emwwoBIionHsqTkzuDrfqJ+ZJe64y9NFlRMmxLu5Yic60Y Z+GQ== 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=BXD7mZaw6n7Frr/mGvCeKqk3NudOAoZm/oyIbjL/Fsg=; b=nTzmguh7rPGfMSfV/8kGohPABPIRs/4dhELGauU2fbHN8/7Hwjnyy1RqQ9GOaAiD8x bIpuQMwW7A/uojr0HyiVUlw56H85emYizXyg+gPVRV48HDf4hrKiWzNawuUUszqHpGU9 +aJE8FZ4ZdWn6qQ2SzVn8bbrKIV1SBhHff0EWfPo8Jjb1mb7N13QxutO383GkzkLeWQC NI00g2SGAFJ64/Te/YjCZlReQQanEK9POmGglJJFTifqrsfZzdbg8SIVPOYMFr4Z42he 2DpjSXDH7VPPk1jG3EcARqLJ1sTVkZEMVVNB5tmchIIrl2onJsW/IBx9Rr3hHkMPWjRs c2HA== X-Gm-Message-State: ALQs6tDyLQqGAlD3nT6oBiq1rhOd1w+6piutMLDMbs032x1/LKuIyY5q nMm36X2PFcVKFCjLlU9N1rw= X-Received: by 2002:a17:902:a9c2:: with SMTP id b2-v6mr5178957plr.181.1523286240885; Mon, 09 Apr 2018 08:04:00 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:39e9:70fb:21a6:f4d2]) by smtp.gmail.com with ESMTPSA id x27sm1327493pfa.134.2018.04.09.08.03.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Apr 2018 08:04:00 -0700 (PDT) From: Jia-Ju Bai To: boris.ostrovsky@oracle.com, jgross@suse.com, gregkh@linuxfoundation.org Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/4] xen: xen-pciback: Replace GFP_ATOMIC with GFP_KERNEL in pcistub_init_device Date: Mon, 9 Apr 2018 23:03:53 +0800 Message-Id: <1523286233-26392-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 pcistub_init_device() is never called in atomic context. The call chain ending up at pcistub_init_device() is: [1] pcistub_init_device() <- pcistub_seize() <- pcistub_probe() [2] pcistub_init_device() <- pcistub_init_devices_late() <- xen_pcibk_init() pcistub_probe() is only set as ".probe" in struct pci_driver. xen_pcibk_init() is is only set as a parameter of module_init(). These functions are not called in atomic context. Despite never getting called from atomic context, pcistub_init_device() 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/xen/xen-pciback/pci_stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 9e480fd..bf8c0d3 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -364,7 +364,7 @@ static int pcistub_init_device(struct pci_dev *dev) * here and then to call kfree(pci_get_drvdata(psdev->dev)). */ dev_data = kzalloc(sizeof(*dev_data) + strlen(DRV_NAME "[]") - + strlen(pci_name(dev)) + 1, GFP_ATOMIC); + + strlen(pci_name(dev)) + 1, GFP_KERNEL); if (!dev_data) { err = -ENOMEM; goto out; -- 1.9.1