[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YFxF6/LerP9OD8n9@rric.localdomain>
Date: Thu, 25 Mar 2021 09:12:27 +0100
From: Robert Richter <rrichter@....com>
To: Dan Williams <dan.j.williams@...el.com>
Cc: Ira Weiny <ira.weiny@...el.com>,
Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>,
Ben Widawsky <ben.widawsky@...el.com>,
linux-cxl@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cxl/mem: Force array size of mem_commands[] to
CXL_MEM_COMMAND_ID_MAX
On 24.03.21 12:08:20, Dan Williams wrote:
> On Wed, Mar 24, 2021 at 11:43 AM Ira Weiny <ira.weiny@...el.com> wrote:
> > Can't we use ARRAY_SIZE?
>
> An ARRAY_SIZE() check in cxl_validate_cmd_from_user() would work too,
> but it wouldn't give the compiler protection that Robert mentions for
> going the other way where mem_commands tries to add an entry that is
> out of bounds relative to CXL_CMDS.
I was considering that too. Another reason apart from above was to
treat 'holes' in the array caused by #ifdefs the same regardless its
position in the array. Thus, all should show up as being zeroed
instead of cutting those at the end from the array.
Thanks for applying,
-Robert
Powered by blists - more mailing lists