From b42f5d8ada93abd0d609a19d5ec1630cd9c9bf4d Mon Sep 17 00:00:00 2001 From: Joshua Cha Date: Thu, 22 May 2025 15:33:12 +0900 Subject: [PATCH] nvsciipc: add put_cred() Added missing put_cred() after using get_current_cred() JIRA NVIPC-3520 Bug 5300203 Change-Id: Iddfb1ae78bb265109709360746b315bd1e62561b Signed-off-by: Joshua Cha Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3369157 Reviewed-by: Jungho Kim GVS: buildbot_gerritrpt Reviewed-by: svcacv Reviewed-by: Simon Je --- drivers/misc/nvsciipc/nvsciipc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/misc/nvsciipc/nvsciipc.c b/drivers/misc/nvsciipc/nvsciipc.c index ba9eab65..9f4c330f 100644 --- a/drivers/misc/nvsciipc/nvsciipc.c +++ b/drivers/misc/nvsciipc/nvsciipc.c @@ -317,6 +317,7 @@ static int nvsciipc_ioctl_get_db_by_idx(struct nvsciipc *ctx, unsigned int cmd, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) { ERR("%s[%d] need to set endpoint database first\n", __func__, get_current()->tgid); @@ -383,6 +384,7 @@ static int nvsciipc_ioctl_reserve_ep(struct nvsciipc *ctx, unsigned int cmd, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); /* Authenticate the client process with valid UID */ if ((ctx->db[i]->uid != 0xFFFFFFFF) && (uid != 0) && (uid != ctx->db[i]->uid)) { @@ -486,6 +488,7 @@ static int nvsciipc_ioctl_get_db_by_name(struct nvsciipc *ctx, unsigned int cmd, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); /* Authenticate the client process with valid UID */ if ((ctx->db[i]->uid != 0xFFFFFFFF) && (uid != 0) && (uid != ctx->db[i]->uid)) { @@ -536,6 +539,7 @@ static int nvsciipc_ioctl_get_db_by_vuid(struct nvsciipc *ctx, unsigned int cmd, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); /* Authenticate the client process with valid UID */ if ((ctx->db[i]->uid != 0xFFFFFFFF) && (uid != 0) && (uid != ctx->db[i]->uid)) { @@ -589,6 +593,7 @@ static int nvsciipc_ioctl_get_vuid(struct nvsciipc *ctx, unsigned int cmd, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); /* Authenticate the client process with valid UID */ if ((ctx->db[i]->uid != 0xFFFFFFFF) && (uid != 0) && (uid != ctx->db[i]->uid)) { @@ -624,6 +629,7 @@ static int nvsciipc_ioctl_set_db(struct nvsciipc *ctx, unsigned int cmd, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); INFO("set_db start\n"); #if defined(CONFIG_ANDROID) || defined(CONFIG_TEGRA_SYSTEM_TYPE_ACK) @@ -901,6 +907,7 @@ static ssize_t nvsciipc_dbg_read(struct file *filp, char __user *buf, struct cred const *cred = get_current_cred(); uid_t const uid = cred->uid.val; + put_cred(cred); /* check root user */ if ((uid != 0) && (uid != s_nvsciipc_uid)) { ERR("no permission to read db\n");