From: Peng Fan <van.freenix@gmail.com>
To: Peng Fan <peng.fan@nxp.com>
Cc: jens.wiklander@linaro.org, linux-kernel@vger.kernel.org,
linux-imx@nxp.com
Subject: Re: [PATCH] tee: correct max value for id allocation
Date: Fri, 23 Feb 2018 10:43:20 +0800 [thread overview]
Message-ID: <20180223024320.GA321@shlinux2> (raw)
In-Reply-To: <20180115092735.20969-1-peng.fan@nxp.com>
Hi Jens,
Any comments on this patch?
Thanks,
Peng
On Mon, Jan 15, 2018 at 05:27:35PM +0800, Peng Fan wrote:
>The privileged dev id range is [TEE_NUM_DEVICES / 2, TEE_NUM_DEVICES).
>The non-privileged dev id range is [0, TEE_NUM_DEVICES / 2).
>
>So when finding a slot for them, need to use different max value.
>
>Signed-off-by: Peng Fan <peng.fan@nxp.com>
>Cc: Jens Wiklander <jens.wiklander@linaro.org>
>---
> drivers/tee/tee_core.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
>index 3d49ac2e3c84..d1f4ecdbc8cc 100644
>--- a/drivers/tee/tee_core.c
>+++ b/drivers/tee/tee_core.c
>@@ -701,7 +701,7 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
> {
> struct tee_device *teedev;
> void *ret;
>- int rc;
>+ int rc, max_id;
> int offs = 0;
>
> if (!teedesc || !teedesc->name || !teedesc->ops ||
>@@ -715,16 +715,20 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
> goto err;
> }
>
>- if (teedesc->flags & TEE_DESC_PRIVILEGED)
>+ max_id = TEE_NUM_DEVICES / 2;
>+
>+ if (teedesc->flags & TEE_DESC_PRIVILEGED) {
> offs = TEE_NUM_DEVICES / 2;
>+ max_id = TEE_NUM_DEVICES;
>+ }
>
> spin_lock(&driver_lock);
>- teedev->id = find_next_zero_bit(dev_mask, TEE_NUM_DEVICES, offs);
>- if (teedev->id < TEE_NUM_DEVICES)
>+ teedev->id = find_next_zero_bit(dev_mask, max_id, offs);
>+ if (teedev->id < max_id)
> set_bit(teedev->id, dev_mask);
> spin_unlock(&driver_lock);
>
>- if (teedev->id >= TEE_NUM_DEVICES) {
>+ if (teedev->id >= max_id) {
> ret = ERR_PTR(-ENOMEM);
> goto err;
> }
>--
>2.14.1
>
--
next prev parent reply other threads:[~2018-02-23 2:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 9:27 [PATCH] tee: correct max value for id allocation Peng Fan
2018-02-23 2:43 ` Peng Fan [this message]
2018-02-26 6:47 ` Jens Wiklander
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=20180223024320.GA321@shlinux2 \
--to=van.freenix@gmail.com \
--cc=jens.wiklander@linaro.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox