From: Souptick Joarder <jrdr.linux@gmail.com>
To: jens.wiklander@linaro.org
Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org,
Souptick Joarder <jrdr.linux@gmail.com>,
John Hubbard <jhubbard@nvidia.com>
Subject: [PATCH] tee/tee_shm.c: Fix error handling path
Date: Sun, 13 Sep 2020 10:12:11 +0530 [thread overview]
Message-ID: <1599972131-31770-1-git-send-email-jrdr.linux@gmail.com> (raw)
When shm->num_pages <= 0, we should avoid calling
release_registered_pages() in error handling path.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
---
drivers/tee/tee_shm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 00472f5..e517d9f 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -260,8 +260,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
rc = get_kernel_pages(kiov, num_pages, 0, shm->pages);
kfree(kiov);
}
- if (rc > 0)
- shm->num_pages = rc;
+ shm->num_pages = rc;
if (rc != num_pages) {
if (rc >= 0)
rc = -ENOMEM;
@@ -309,7 +308,9 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
idr_remove(&teedev->idr, shm->id);
mutex_unlock(&teedev->mutex);
}
- release_registered_pages(shm);
+ if (shm->pages && (shm->num_pages > 0))
+ release_registered_pages(shm);
+
}
kfree(shm);
teedev_ctx_put(ctx);
--
1.9.1
next reply other threads:[~2020-09-13 4:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-13 4:42 Souptick Joarder [this message]
2020-09-13 20:29 ` [PATCH] tee/tee_shm.c: Fix error handling path Jens Wiklander
2020-09-14 1:39 ` Souptick Joarder
[not found] <641dfe3b-1de8-97ea-eac7-89d81846eab3@web.de>
2020-09-13 13:01 ` Souptick Joarder
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=1599972131-31770-1-git-send-email-jrdr.linux@gmail.com \
--to=jrdr.linux@gmail.com \
--cc=jens.wiklander@linaro.org \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=op-tee@lists.trustedfirmware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox