Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp430097ybm; Thu, 28 May 2020 06:31:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv6xBjd2utyN3vkbiz4Wx/M8qt1hx8sqFbt/fDz0MMT11j8lgg9oGJt02U1kuHNRRhvCoX X-Received: by 2002:a17:906:fcb9:: with SMTP id qw25mr3156812ejb.326.1590672705151; Thu, 28 May 2020 06:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590672705; cv=none; d=google.com; s=arc-20160816; b=rN0yO0p4jPjEDsnmoEgswEqnKNJ0+wxxLuYB/hdUI5nedqtTroABcFXZqj7rjtr43e Eks18Biq41vLcNPAoiS+YRE08Ivw5eOIKzqJjvS6/EjfWgUPf6WuIQ/OMQhF1ktD3hE/ 1mbDXlRwrVYCttftqnNcDGKsABrVzfccuXLKFIljkDyzIv8SvJlJA8V5WMsNVeovCU/c DD4C3Llkwro+sKDuVV50gd9udU16xg/8xDlV1ko2vgRuAsVJt3dKxtvT1Hib/tTxM5K/ XpbJ5o3oP3lVPo3VcgT0DhtzkwhFCYEtrW7JBHuDZOAce52pYBixxHcXqdAkvNGZxxDr Ez1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=e89vVvPWcp0gmx4b9jHmj//eUvZNgypMTmBwdEznPVA=; b=R/0Ci6u2S7tuTbPBytP1uUJYn/WMb3fj1DI9aEiT3a3+2nCM9jZe2s/W7qku5xpmcN qUErQLRAqJ5hCZLsEeRD4F6V4DOl4FGcLMs4W9604l33rl2VuWBLHhVMMngAiqCNODw3 bc6xrZOmVdnXjI+cHBGQEAGRRLNkb+sSbTVUNUjPqwTp/DGaivOt+2UHl/kg55gI/5Lb 7MCnVlqfgXYQ4ypcqolRg4tgGurGn7hysI7NfTfc6gV7uWPjwb8/ekKiFqz27+6kV3JA dgtLbDLKHnHg4W1BRVxjqonfLXXmlaJNMErMGUMqEKftxt/bXougR2OmvJnbWozc2qOI AXOQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3688223ejz.137.2020.05.28.06.31.21; Thu, 28 May 2020 06:31:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390420AbgE1N3h (ORCPT + 99 others); Thu, 28 May 2020 09:29:37 -0400 Received: from mga01.intel.com ([192.55.52.88]:51113 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390268AbgE1N31 (ORCPT ); Thu, 28 May 2020 09:29:27 -0400 IronPort-SDR: UPqMpgb3Vzkft9vUwQBNQv7QqQXab5qwWPC98lOChVx96dZRE9CP27EWXMvK6ZwrrqDppX6XLt Avgm3j4zIFIw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 06:29:08 -0700 IronPort-SDR: MozizEa8xAPoZoFX9CZ+NW/XPcsd+925xotRcz12t/DE4MVoSwuXmtTFz2rCXO/PPJ9l2gb4qQ vrZvQpRZrMZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,444,1583222400"; d="scan'208";a="376367141" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.21]) by fmsmga001.fm.intel.com with ESMTP; 28 May 2020 06:29:08 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 23E06301C5F; Thu, 28 May 2020 06:29:08 -0700 (PDT) Date: Thu, 28 May 2020 06:29:08 -0700 From: Andi Kleen To: kan.liang@linux.intel.com Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, David.Laight@aculab.com Subject: Re: [PATCH V2 2/3] perf/x86/intel/uncore: Record the size of mapped area Message-ID: <20200528132908.GG611145@tassilo.jf.intel.com> References: <1590671727-99311-1-git-send-email-kan.liang@linux.intel.com> <1590671727-99311-2-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1590671727-99311-2-git-send-email-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 06:15:26AM -0700, kan.liang@linux.intel.com wrote: > - box->io_addr = ioremap(addr, SNB_UNCORE_PCI_IMC_MAP_SIZE); > + if (!type->mmio_map_size) { > + pr_warn("perf uncore: Cannot ioremap for %s. Size of map area is 0.\n", > + type->name); > + return; > + } Is that likely that the size is 0? In any case you have to test the return value of ioremap. So I would rather test the address for 0 than the size. Similar in other code below. I thought you were going to add a range check based on the size to the actual access. Did I miss it in the patch? -Andi