Signed-off-by: Ryan Lee <[email protected]>
---
 security/apparmor/lsm.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index d158c5108f0e..a30a17afe4b3 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -786,19 +786,20 @@ static int apparmor_getselfattr(unsigned int attr, struct 
lsm_ctx __user *lx,
        int error = -ENOENT;
        struct aa_task_ctx *ctx = task_ctx(current);
        struct aa_label *label = NULL;
+       bool needput = false;
        char *value = NULL;
 
        switch (attr) {
        case LSM_ATTR_CURRENT:
-               label = aa_get_newest_label(cred_label(current_cred()));
+               label = aa_get_newest_cred_label_condref(current_cred(), 
&needput);
                break;
        case LSM_ATTR_PREV:
                if (ctx->previous)
-                       label = aa_get_newest_label(ctx->previous);
+                       label = aa_get_newest_label_condref(ctx->previous, 
&needput);
                break;
        case LSM_ATTR_EXEC:
                if (ctx->onexec)
-                       label = aa_get_newest_label(ctx->onexec);
+                       label = aa_get_newest_label_condref(ctx->onexec, 
&needput);
                break;
        default:
                error = -EOPNOTSUPP;
@@ -813,7 +814,7 @@ static int apparmor_getselfattr(unsigned int attr, struct 
lsm_ctx __user *lx,
                kfree(value);
        }
 
-       aa_put_label(label);
+       aa_put_label_condref(label, needput);
 
        if (error < 0)
                return error;
-- 
2.43.0


Reply via email to