Re: [PATCH V2 2/3] perf/x86/intel/uncore: Record the size of mapped area

From: Andi Kleen
Date: Thu May 28 2020 - 09:29:39 EST


On Thu, May 28, 2020 at 06:15:26AM -0700, kan.liang@xxxxxxxxxxxxxxx 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