Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2371075pxb; Mon, 20 Sep 2021 20:27:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx/JXCqvP3iG3NAe5hCBqwopTrYo7tRhbOut0IzOLzK5D43Nrw58gjk6GtDxkVNBc6x+Hu X-Received: by 2002:a17:907:75da:: with SMTP id jl26mr32329884ejc.300.1632194858887; Mon, 20 Sep 2021 20:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632194858; cv=none; d=google.com; s=arc-20160816; b=MRQVsGYQScQR3OZqeX+GNeAjB2iZf4zP5NL12RZYvdu+XQM6HN2kYilMopvzqMWOEe fWOfjcimtsw4nXtG0uZenCQDQRcrqYyk3yYoUEYHSwdMiukBvdprkq1JvqndFtSOxrNS Zmox58h/Epbjt+eoj4hEl55weN+0IM9nPCee+1gxPaN+jbpmRfNriaA75OARVIl01oTA VRMEout81DS84lAd0MBzeczM1DYsryLeNOlbU62ZxcpSjHHNvYVOhJPrzamy3NpA0SqA ktcJXE7re51PnCN94U/Yjh3bfb5HCwv/Sheu1fCxqztmiE8zC4xGJPbGtdmNBHEKFlV3 IdGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aYWFUbUV9DDlQ5siYYXKPiyMIgK+dJcBQd1Gq0dTJPk=; b=FXYe5wqi7NJQm0LVHwIt6ePpwQ0D0TTWKHvQXAYv80MRy+tTLBhwxJ0fSLIKePbClr jNn28OMzpJTwBWBKPpeGn0aYzZIxYyTnAf+tE8N6FN9I5rTBLRfuG5XBh1T06qEq5O1y ADW0VbC5hjgrDKUbKrLib1qX7Iz9ECPTjJlcyII2sFKeDiu7xs3FHqcF/SScgde4lrie 7kPZoMjKMeoSU9WSODcXCvb7kKRiFCTmjBv+jMqYiLirN9KPWFdzlH0wrdZONn4Ii3YH eRKXm5VSjshYmd3ef9oSh1w6jZi6rZc0jvu/YQ9zRtWc5fr1KKYnneVzSFtj7tCxtaj8 kHqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XrTXB50A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si18191607eda.351.2021.09.20.20.27.15; Mon, 20 Sep 2021 20:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XrTXB50A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379091AbhITS17 (ORCPT + 99 others); Mon, 20 Sep 2021 14:27:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:43766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377865AbhITSV0 (ORCPT ); Mon, 20 Sep 2021 14:21:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9055A632B3; Mon, 20 Sep 2021 17:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158639; bh=4yDISMmyrm+cG+A5+reyGD82tQKcWXQHwS2eIO1obUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XrTXB50AwG2Bl9KfUle5ZXjPlyHzZ/2wOPm1ZqeYZ8GjhAheloQuldIFzu5ZTlzk/ haB/g69agTZr22UqeyRV+Mg+iGfGmHL8SQmEO7DIW5gVefIAaaLkwWwqX73rS1/9eu K71xaSXhyYErVQjP0N2oXQCXs1iJacyuUgrYP/DE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Bjorn Helgaas , Logan Gunthorpe , Sasha Levin Subject: [PATCH 5.4 248/260] PCI: Fix pci_dev_str_match_path() alloc while atomic bug Date: Mon, 20 Sep 2021 18:44:26 +0200 Message-Id: <20210920163939.541069072@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 7eb6ea4148579b85540a41d57bcec315b8af8ff8 ] pci_dev_str_match_path() is often called with a spinlock held so the allocation has to be atomic. The call tree is: pci_specified_resource_alignment() <-- takes spin_lock(); pci_dev_str_match() pci_dev_str_match_path() Fixes: 45db33709ccc ("PCI: Allow specifying devices using a base bus and path of devfns") Link: https://lore.kernel.org/r/20210812070004.GC31863@kili Signed-off-by: Dan Carpenter Signed-off-by: Bjorn Helgaas Reviewed-by: Logan Gunthorpe Signed-off-by: Sasha Levin --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 91b2733ded17..b9550cd4280c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -224,7 +224,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path, *endptr = strchrnul(path, ';'); - wpath = kmemdup_nul(path, *endptr - path, GFP_KERNEL); + wpath = kmemdup_nul(path, *endptr - path, GFP_ATOMIC); if (!wpath) return -ENOMEM; -- 2.30.2