Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp204591ima; Fri, 15 Mar 2019 00:30:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuPjFA6Qtxa5SuUR3S/YDjdYb5HusjR1XhtSleqwPIO5Dk+dGlHvK1s3KTD+D6r1vbJjYI X-Received: by 2002:a63:694a:: with SMTP id e71mr2043904pgc.129.1552635049666; Fri, 15 Mar 2019 00:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552635049; cv=none; d=google.com; s=arc-20160816; b=vaE3GLzsqF5lzYf7kenScW0XSy5hc2TNxzP4W3kIGuFMFOOJmdxcg+JTu3yTLMbcsm CX4yRq2W6sqFtrsJJBwIMkwtzNaWwrwtg+yEMCQoCTzWtLwd4apz2OGxTAHIrJ+35IVs ITKDhhDF+rEWuEU4CfxD3KBDLb4Um+NHw8BOMFXNrGXnfZzCqKEn1Kfi5TDZg2++nB2q xjSDhrGO62a2hA0EYU+/Hzmh82dsFoEIat2FxPmvsbLNwK01E0DtnNxCwZCkPEnZz6+L hrGOPM3ioMJ9/9JdmOFQdWAkmyKqiKUpIZydVfzW724R+fOdPztXhmkoxsHuvpdCnZYF wn2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Xy7x4Tgo9JSLzKOlvBWwqGv6Hh3KCpHu92BvLfEbekw=; b=o6uRkwkqDzQxW+dWaRK7omUngopxNeGmPP1J4swWCRINxL5iOaNoqqlnbRDV/6V77m iXWJSkekJDidrAZ//e47TvngkN4U3PLoeq+f8f+7SgSqqzkk0Cj7sgNP1n66gq8ycKn1 GxmOtaL9gS4DqfncKCTI6KMt3CQnlyqs7wtygRijFtjWDa2K2phXEk0PNHnFS25gSg5i 2abi+YF39JRXLGN5D9N2JTH1dX0ihuIOQiMHPmqRoZvfg606qvp4wBjloEm7i2VRywSX K9SSHVsSxxRWb+xkTOt17t8+UkGAwOydrFwG5VlQp12xxN7JrjVJy2bxOLx0vC8Hrwtx IeFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=pGkKxMMc; 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=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1244483pfh.236.2019.03.15.00.30.34; Fri, 15 Mar 2019 00:30:49 -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=@umn.edu header.s=google header.b=pGkKxMMc; 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=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728452AbfCOH34 (ORCPT + 99 others); Fri, 15 Mar 2019 03:29:56 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:56810 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728350AbfCOH3y (ORCPT ); Fri, 15 Mar 2019 03:29:54 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id A0602CFC for ; Fri, 15 Mar 2019 07:29:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9dIpt0kziNzn for ; Fri, 15 Mar 2019 02:29:53 -0500 (CDT) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id 68F1EA5E for ; Fri, 15 Mar 2019 02:29:53 -0500 (CDT) Received: by mail-it1-f199.google.com with SMTP id 9so6881624ita.8 for ; Fri, 15 Mar 2019 00:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xy7x4Tgo9JSLzKOlvBWwqGv6Hh3KCpHu92BvLfEbekw=; b=pGkKxMMcYTA+4ibgxCnLx3W8wdAHRV1er6127G3dsauH1uTrUPmdElNm/U53Xnv/m9 Aq6H5VTWKKJFBNG05qI2/i6KKs6BAwAFH5Qp+X9VtQX1owC2SK8uPjwnIa3bU/VK5xF7 03lqNgaMOhQlz1cb13nPWbEmpDWQaP055L86zCHVecQsInq20oGNIW1ZPzHrHqAEobGo UbGToY6JbdKUTz65+GwN27aFmDtJhwtUudKTuWijC20r0FJw9tYgf/RQCHSqmGcVENLK Ns7GRgEjs6sRuZNMTemG8WuvD/Ew78cnEJClbmhC0ampct/hWFxS1qQqtQeZIEqeCITG PvkQ== 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:in-reply-to :references; bh=Xy7x4Tgo9JSLzKOlvBWwqGv6Hh3KCpHu92BvLfEbekw=; b=qX2Nu6G8NwW9p/aM798IliKfc4dmVlkzMyPuXimejdS6YdsDlDY6xx0BYc+yj0SXEx sPlKHifWSacS4myOweCN4lxQlMCavsbvS+kr/xedixlZnI5QJBGFkG1kiX1yZts3j20d vJENhikx8rg2F8mYKAB9h5JMtFDkEocQPQV5imgIeJqKvJx3Nb+JrkzuaKL8ZC0g/4Xw f4tFX4CDKphzK1gzZBeDZRYelNirZI5AXqt5K6vsHfkj7hVtZELZP8rriFMAhfCJuMbk 3MHuLlg1VWaAMVIrlrhCE/0oZTh8Z8noSXuBdfuvxjmExCBIt4u1ucQqvEyGzRGJGxPj wdWw== X-Gm-Message-State: APjAAAUwYfGdeIVy7n2DmsKES411OHYzad7Fms4XETCmSV029xp5QWK8 oSdUIrNX5+w/gYZi3nrWgfqIPBhA1Ec3X9o7N4LMuWV8IC4CR6S2MSae4jtSUec7LgyFG0bCPMG H3qDK2aueMPVGizTXfkbgmb1XXs95 X-Received: by 2002:a5e:dc0a:: with SMTP id b10mr1444090iok.34.1552634992979; Fri, 15 Mar 2019 00:29:52 -0700 (PDT) X-Received: by 2002:a5e:dc0a:: with SMTP id b10mr1444077iok.34.1552634992742; Fri, 15 Mar 2019 00:29:52 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id o141sm707418ito.14.2019.03.15.00.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 00:29:52 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: Simon Horman , Lorenzo Pieralisi , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] pci: pcie-rcar: fix a potential NULL pointer dereference Date: Fri, 15 Mar 2019 02:29:43 -0500 Message-Id: <20190315072943.22923-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case __get_free_pages fails and returns NULL, the fix returns -ENOMEM and releases resources to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu Reviewed-by: Geert Uytterhoeven --- V2 removes the error message. --- drivers/pci/controller/pcie-rcar.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index c8febb009454..71e55995c058 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -929,6 +929,10 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) /* setup MSI data target */ msi->pages = __get_free_pages(GFP_KERNEL, 0); + if (!msi->pages) { + err = -ENOMEM; + goto err; + } base = virt_to_phys((void *)msi->pages); rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR); -- 2.17.1