Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3622704imc; Thu, 14 Mar 2019 01:08:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqycOf/1tx+lH6yfk4X0zGgmumQIgoMuMkl8kGhTQ3zz8oLwqfXdVzcNYqDaf01lcL03CncM X-Received: by 2002:a63:6949:: with SMTP id e70mr43486447pgc.89.1552550932822; Thu, 14 Mar 2019 01:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552550932; cv=none; d=google.com; s=arc-20160816; b=T9Jk77EvuTKUuWpRTYevA7ruDvViI4qPeLSZYaM4RNEh08RovtJwsVbQgXaLSCVzNM B+3y0qQpvIR9VF+rHUGujAVB/PLeWVRDw+CNl6wHMHrEnais151KyB13GYZLpU7CFCLC zCoJItEiVH6shI8mx6+4ggjmdx8UtzrEKGqzJPbMnEXNErJ1YeLeUaZk6qdEXApdh+Ad Pg3UtDtb1YLUrvE+CbI+1ezrR1Y3b0m0kUyNwaTkIZmZdSs3//oL2KNulABdRKA2vzMK Pe7tOMeDJGIJVM5mTzkmEV6Azv+yZnUW7Z8PSsYiFMK/PXxACcHSOejeANX2OmcpKtbn lkJA== 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=Kb2MUkZrbDxyWVobIVoD47XbUyDSTUuGSgsDc9X7Vv0=; b=lDBrCidCGO+6Z0AIH3Cc+fNLHd0nDK7M3jdFYAtf5jI6ouJ8TZ1Qq++zVX2MlusKq+ cl4KorS4AbnLsQ81V4AuZvpG8e8HkKAcgHLkAsXf9+Upftohkey7EKKL4FC6gbBCtaCW 7BxJ95MOYUSOpVSdSCfmIDDjB3tygWTjiFucBRjEfVtzhznSWry+DWpau2gX/F1Bttjx LmvCYZjc6BiC1UoYuOZFBDmdXWD4RMLt/ja4KfIS6yf5tRlrf5VIAYO/ldw6r84eMkq/ 2EjrGztwj5HMpclvpHY+mcoXxSX+En/QHn0k2aWMUBez8zM92GfwQs2Z22wW9cC+b59N 509g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b="db/phBQP"; 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 g11si5114743plo.125.2019.03.14.01.08.37; Thu, 14 Mar 2019 01:08:52 -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="db/phBQP"; 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 S1727001AbfCNIH5 (ORCPT + 99 others); Thu, 14 Mar 2019 04:07:57 -0400 Received: from mta-p8.oit.umn.edu ([134.84.196.208]:39020 "EHLO mta-p8.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfCNIH5 (ORCPT ); Thu, 14 Mar 2019 04:07:57 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 0BD0DC5C for ; Thu, 14 Mar 2019 08:07:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DpbvCWIskuo2 for ; Thu, 14 Mar 2019 03:07:55 -0500 (CDT) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id CCB1EBAF for ; Thu, 14 Mar 2019 03:07:55 -0500 (CDT) Received: by mail-it1-f200.google.com with SMTP id w200so3975583itc.8 for ; Thu, 14 Mar 2019 01:07:55 -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=Kb2MUkZrbDxyWVobIVoD47XbUyDSTUuGSgsDc9X7Vv0=; b=db/phBQPaF9vHVY26K/yZUaF1vg/gHllaz8t716IUQj36Sxc+X52bmEjptTugm+chI hrmZRKH0LxwSwLRLVIX6nGypGLsSDLU64cpHyOGjEzGhn3EqL1VrC2eyzYQyo7dRcFBl rXFKN+TUgHq+MWHbL7eccoEHWrnz1n7nXp2vU8B1hT7m5TwhIJalg/NA2q4B3s4YUGZL KeLbajJiuBn4OAvD0LENW6GpC3ip124g5bkNCpqLNljJM+kZejCJixwRfe8Y+EFxM44q A7ywwIOHzbEEp3aVz1AGglJYAZqxUWW8tIVLEYoXHg+63Ec1MjAeqN5zloxWsqQQDays VEHA== 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=Kb2MUkZrbDxyWVobIVoD47XbUyDSTUuGSgsDc9X7Vv0=; b=oTOyfZwhj1Jgy4WB5c6I4qV9VR7zg3/ZeQUM1fTvYdona41ZS+QTQgqgOlACi/eSMa /rjRlgL/sbnBdHVXexL6mS1WQOUT3ZXJ+Hl+Mrgr93kiOiocEejA1lVDu1sqK8hVoPNp RSd25m0rk5BKtlI5SdkDlKgrF5nRxWXf8HMDf0UZrAerjkz/+qbW3txw+rdRvigwx16t NwveZc1mvE/FKhbsDvSfldoitXd9k42RK/wzbeNpPc9LWP4Yw2yhv37rVwVvOINYqMWK ZnC0WtTlmBTeC/sYZqmaqgLxlPZQG5xxmUHIBIC/0r+ddL+zVfIwVXNONx3zfbOFeL3S T7FQ== X-Gm-Message-State: APjAAAW3B+SRddZ8mpK9LyuGBzU/mT11n+w8ACCY5et+pMEs/ix56W0W tijPJECX/8/MU2U0ce+1B9VRf698LfveXWQR6q/AQ5Mwhqbd4HWJWqibTqMxu8U9SBty/5jQpvV WlMtxF017ym4RdcBDQX3Xck7u73N0 X-Received: by 2002:a24:1947:: with SMTP id b68mr1108971itb.121.1552550875413; Thu, 14 Mar 2019 01:07:55 -0700 (PDT) X-Received: by 2002:a24:1947:: with SMTP id b68mr1108966itb.121.1552550875171; Thu, 14 Mar 2019 01:07:55 -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 b202sm786154itb.36.2019.03.14.01.07.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 01:07:54 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, 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: Thu, 14 Mar 2019 03:07:41 -0500 Message-Id: <20190314080741.31983-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 --- 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