Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3602670imc; Thu, 14 Mar 2019 00:31:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLNeGZ0TBX1svvkS62D+VWtL5LUMwDtB9qCGrQrOE6+/I5Ni1/Uc1cKhyfPmzi89lw00p4 X-Received: by 2002:a62:a509:: with SMTP id v9mr11399304pfm.64.1552548680682; Thu, 14 Mar 2019 00:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552548680; cv=none; d=google.com; s=arc-20160816; b=0chqK8cklaYrk283QPX7L6yE9Gc68i7NOXS98TXD7j0kGVLoA8hGJsgORmidJS2M8s N3fjoJ/Dl/J2Lqu+O250dBSxzq87hwjJbl3Yb9WXEZ7NUZX21MBTP0Ar3v/XPVI47yeG a3SVRpcORNgcK95bfBrDCWQAbskDeF6ysiT8t2BZkFZsobSo8W5wtHrtNPVzMJTor9I3 lrliHChNFYZSHbaPOfuSso8bAADpQj6GDS9XITn2/FefSRfqKjtytg6l8PRg3n3WIfK3 Rwyrcb7jxyb+aLVQK27NAGp30aWDGqWlvoTHSzXRQoJUd+tdNwQSy1qSepUEV0oWd1Q8 75GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=7L5fel6JCqFPZpkNzFwwfkIvlfvqIt2Q2h0Ef4ZsU6o=; b=gMPIOanoej5rjXvgjpY1S7m25WUhQPFSB4nZP1zJMoDKaZ3x7fih3gYwWok0fs4ceO DywwpwMCGOJ/IpWfEob9WusaWDAF8xxZJAEF/0TF2so63P53T0sRJ8BomvpjhDFgMw0w RcNx46zcsWb3f6eWn6M27Gzwsl5iPX0VGq8iG1LiaJTJkEsFBxMv3kCXoKJhjfZtl1R3 vDzqm6M/pwhGGALAVY2APMar9U19S8mNf1MISM32B5kE0KrZhFdd9YzAZ+sb0iyo/hwh awDv6f/0j7eHnhCJ3LfAaKZ2bbENxZ9tH14oI4NoxY0FnPEcPJczwgea+pX0pPQQpo33 VGVg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 59si10523252plc.84.2019.03.14.00.31.05; Thu, 14 Mar 2019 00:31:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfCNHaU (ORCPT + 99 others); Thu, 14 Mar 2019 03:30:20 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:37517 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbfCNHaU (ORCPT ); Thu, 14 Mar 2019 03:30:20 -0400 Received: by mail-vs1-f68.google.com with SMTP id y19so2637118vsc.4; Thu, 14 Mar 2019 00:30:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7L5fel6JCqFPZpkNzFwwfkIvlfvqIt2Q2h0Ef4ZsU6o=; b=RShXDCl6YG2Yb89640nvbwBgcI0ya535jI7aCG1hgfjxTABZzm+4xUFoQE/WMMJ3lS OIkEYW3MiKHtcDPBzEjbZdBB3oAhkv6qZvPRsVVZ03jPt5NJvaREXdEJhpAls1nqLSwK DXRJbUwQMSkaegUJ6bGsuH8hXPZZWo63Opx2aTbvIi5/OzU1hSwOa8cHH0rpp4IdUtar AtUugOmYo6xLegE7lM2FYv7CzQTQUE3lkXIqLyL/l+rHvLOIi1mHGlKOYb7GG+CvHEtH I//aTj5HT9dG+Lz8Nj26I0BOIJWXIPFqvKtQkY7HOatL1QoEBulgbSsa44G15+GCYUKk +1iA== X-Gm-Message-State: APjAAAXS+pXTUE59T1Nmijn2rkqHenmk56ezYS2n92Uhjc3ELqp+BAZy A/kODYwxyfD3T3OwoiqYBq94ytIBSybaSpdYk40= X-Received: by 2002:a67:8588:: with SMTP id h130mr24141458vsd.11.1552548619064; Thu, 14 Mar 2019 00:30:19 -0700 (PDT) MIME-Version: 1.0 References: <20190314055608.5209-1-kjlu@umn.edu> In-Reply-To: <20190314055608.5209-1-kjlu@umn.edu> From: Geert Uytterhoeven Date: Thu, 14 Mar 2019 08:30:07 +0100 Message-ID: Subject: Re: [PATCH] pci: pcie-rcar: fix a potential NULL pointer dereference To: Kangjie Lu Cc: pakki001@umn.edu, Simon Horman , Lorenzo Pieralisi , Bjorn Helgaas , linux-pci , Linux-Renesas , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kangjie, On Thu, Mar 14, 2019 at 6:56 AM Kangjie Lu wrote: > 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 Thanks for your patch! > --- a/drivers/pci/controller/pcie-rcar.c > +++ b/drivers/pci/controller/pcie-rcar.c > @@ -929,6 +929,12 @@ 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) { > + dev_err(dev, "failed to get free pages\n"); Please drop the dev_err(). The memory allocation core will already have printed a warning, cfr. warn_alloc() in mm/page_alloc.c. With that fixed: Reviewed-by: Geert Uytterhoeven > + err = -ENOMEM; > + goto err; > + } > + Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds