Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1275547lqg; Sun, 3 Mar 2024 02:58:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxxxb9IaDhux7nk4bJ+Tod6gxD+AwhQP6WDXAyLPYn9i39ml9myQViD98ndIQxe/rSNS3nHQJ4Tf1FOh6P8veawvt7WN8zwfN29/prbQ== X-Google-Smtp-Source: AGHT+IHPGJYf0xi3rDIcZYwvUw0q6Ign0lZRG6SubL1PYJ1+y5KAHQCeMJLuQa8EiPu5MybqXdEG X-Received: by 2002:a17:906:d28f:b0:a45:110e:568f with SMTP id ay15-20020a170906d28f00b00a45110e568fmr626418ejb.37.1709463485551; Sun, 03 Mar 2024 02:58:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709463485; cv=pass; d=google.com; s=arc-20160816; b=UGq1H/AxmnTlNhrOvxwJ1EaecGE5i0hyIre1JGyaIlWowCv1Ix/+eshXZ2g/zOizUX d6jvIP72ckiXnfMmRMrhvSg8R75H3zK63lLtDsJTVJUVwcRyHs78Z59yVIeE4xBszljV rTr9JncM8VJYWzLv31vTJ030sRc8xD9qIeE3ImS68TwD1Zm1qGNI5n6m5awg5Zs2/qSi fZnMymq7QUzVmiFGZsXp6rN1SH1pCnlffx6ephmKRrobpj/HV/kBpMvsCqC29ivwiNL1 Ii0BSvi8/EqkOKvVneagnE7U1Icp2e/PyjkpVDsaPYof2bqnhsuyDeC6p6idjAabOCOR wnvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=eGGpvADPhzT1SWdlA0kz5wu4gNIK9A0LKGNyqbhnPoE=; fh=Og0+y63n04eqTH1hQVMJQxpr3tnLekpKackgBw1jSXg=; b=V7C3RKELgdpnqAoPHINHDMFWPCeCQ63iTvF0190TAP5A9X4ksLKivOjnpzgPPB5aL9 AXtNmnaKGBwIrexDC4SzeEAFRDDcgNGeO3M/ihX/7jE7SSx+KJyMsYH9tYHzSrPeBYGd dz+nFooxTtn9vYRlyF+n7cnlmDV1y3YMg2jT6Ediku4DMSGoG0OdOpvGxA4IeOLRm1AD Dz8IXDuELJe/snsskxu8GKNRI6eHwkYeJkTCkAEQdk2ASI4WdfIsEWm9vsFaMtKBrFP5 2ejuRdjeTRbXNzs274edt0eB6UcElk0N+1gmDyffsKoaiHcnGLqITi2RnSSYi0laQZJ1 L2vg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-89710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89710-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q16-20020a17090622d000b00a4466b62d7fsi2411780eja.943.2024.03.03.02.58.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 02:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-89710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89710-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3A4F31F21BE6 for ; Sun, 3 Mar 2024 10:58:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69ACCBA5F; Sun, 3 Mar 2024 10:57:56 +0000 (UTC) Received: from zg8tmtu5ljg5lje1ms4xmtka.icoremail.net (zg8tmtu5ljg5lje1ms4xmtka.icoremail.net [159.89.151.119]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA190947B; Sun, 3 Mar 2024 10:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.89.151.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709463475; cv=none; b=ikG6RWvpDe4JEgMrvlmReFKnXAn/wMSU6fnNxFcTxaEPC1WpT4H+dnS1XMOv9aiS0RShGTZRaBv0hd1yy53TtBhdBuGcULJ9OCCfNvkuhSFE22UuskSS0BqVL7alIxhEoU4jzeuiYmqgETQj5K+YsnDCziObPN1hbSziOVib9FA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709463475; c=relaxed/simple; bh=7I1M0XKAfIrhItJO/PERH8zWFQjuo/z2v7W4UV2ieXg=; h=From:To:Cc:Subject:Date:Message-Id; b=jn3zir5SabL5uFK7VdpHSMKh6wSHj/hhJIdqkOi2X19QcxH+N4x2oeIM54fOrp5nC5RiKDj50P6BNHorRi+W84+RajKMUsRx6fDO8ahT4Dxi2QLeq75GgnYNsFsgDT6jbwe9i9unvnKeP8CUHyrFS2j9Cho5FDay8NBhOzERp/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=159.89.151.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from ubuntu.localdomain (unknown [218.12.16.66]) by mail-app2 (Coremail) with SMTP id by_KCgD3OqqZV+RlIRuXAg--.47332S2; Sun, 03 Mar 2024 18:57:38 +0800 (CST) From: Duoming Zhou To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bhelgaas@google.com, Duoming Zhou Subject: [PATCH] PCI: of_property: handle int_map allocation failure Date: Sun, 3 Mar 2024 18:57:29 +0800 Message-Id: <20240303105729.78624-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:by_KCgD3OqqZV+RlIRuXAg--.47332S2 X-Coremail-Antispam: 1UD129KBjvdXoW7JrWDJF1DKw1rZr47XFy8uFg_yoWDXwc_ur ykZ3Z7Cr4UCrnagr1Utan3XrZ7C3W8ZFs3uFn3tFyfCry7ursYqrnrZ3s5JFs7G3yxAF95 ta4UArn5Cr1xWjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbc8FF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_Gw1l 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUoo7KDUUUU X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwIIAWXjdVMBCAA0sV Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The kcalloc() in of_pci_prop_intr_map() will return null if the physical memory has run out. As a result, both int_map and mapp will point to the null area. If we dereference mapp, the null pointer dereference bugs will happen. Return -ENOMEM from of_pci_prop_intr_map() if kcalloc() fails for int_map. Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") Signed-off-by: Duoming Zhou --- drivers/pci/of_property.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index c2c7334152b..03539e50537 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -238,6 +238,8 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs, return 0; int_map = kcalloc(map_sz, sizeof(u32), GFP_KERNEL); + if (!int_map) + return -ENOMEM; mapp = int_map; list_for_each_entry(child, &pdev->subordinate->devices, bus_list) { -- 2.17.1