[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <40422756-cef4-38b1-8554-c99e7bcb7765@intel.com>
Date: Mon, 10 Dec 2018 12:42:14 -0800
From: Reinette Chatre <reinette.chatre@...el.com>
To: Borislav Petkov <bp@...en8.de>
Cc: tglx@...utronix.de, fenghua.yu@...el.com, tony.luck@...el.com,
jithu.joseph@...el.com, mingo@...hat.com, hpa@...or.com,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks
Hi Boris,
On 12/10/2018 11:13 AM, Borislav Petkov wrote:
> On Wed, Nov 28, 2018 at 10:20:27AM -0800, Reinette Chatre wrote:
>> rdt_find_domain() may return an ERR_PTR(), NULL, or a pointer to struct
>> rdt_domain. It is thus required that the return value be checked for the
>> possibility of an ERR_PTR as well as NULL.
>
> Well, it returns ERR_PTR(id) but code which uses ERR_PTR passes in an -E
> value, for example ERR_PTR(-EINVAL) or so, and not an id.
>
> And that might work now if id fits within that MAX_ERRNO range - I'm
> looking at include/linux/err.h - but that's still fragile.
>
Thank you for catching this.
It does seem as though things work at this time since rdt_find_domain()
contains:
if (id < 0)
return ERR_PTR(id);
and from what I can tell the only possible negative value of id is -1.
As you note, this is fragile. Additionally the error, if intending to
use -E values, does not reflect the error (since -1 would mean EPERM).
Would you be ok if the above is changed to
if (id < 0)
return ERR_PTR(-ENOENT);
as part of this patch?
Looking at rdtgroup_mondata_show() is does seem as though ENOENT is the
actual intended error value, although ENODEV could perhaps also be
considered since such a result reflects that a particular cache instance
could not be found.
Thank you!
Reinette
Powered by blists - more mailing lists