From: Reinette Chatre <reinette.chatre@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com,
jithu.joseph@intel.com, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks
Date: Mon, 10 Dec 2018 12:42:14 -0800 [thread overview]
Message-ID: <40422756-cef4-38b1-8554-c99e7bcb7765@intel.com> (raw)
In-Reply-To: <20181210191311.GC5482@zn.tnic>
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
next prev parent reply other threads:[~2018-12-10 20:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-28 18:20 [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks Reinette Chatre
2018-12-10 19:13 ` Borislav Petkov
2018-12-10 20:42 ` Reinette Chatre [this message]
2018-12-10 21:04 ` Borislav Petkov
2018-12-10 21:42 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40422756-cef4-38b1-8554-c99e7bcb7765@intel.com \
--to=reinette.chatre@intel.com \
--cc=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=jithu.joseph@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.