Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
selinux: remove the unneeded result variable
Browse files Browse the repository at this point in the history
Return the value avc_has_perm() directly instead of storing it in
another redundant variable.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Xu Panda <[email protected]>
[PM: subject line tweak]
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
Xu Panda authored and pcmoore committed Sep 14, 2022
1 parent 6354324 commit 09b71ad
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -5986,18 +5986,16 @@ static int selinux_msg_queue_alloc_security(struct kern_ipc_perm *msq)
struct ipc_security_struct *isec;
struct common_audit_data ad;
u32 sid = current_sid();
int rc;

isec = selinux_ipc(msq);
ipc_init_security(isec, SECCLASS_MSGQ);

ad.type = LSM_AUDIT_DATA_IPC;
ad.u.ipc_id = msq->key;

rc = avc_has_perm(&selinux_state,
sid, isec->sid, SECCLASS_MSGQ,
MSGQ__CREATE, &ad);
return rc;
return avc_has_perm(&selinux_state,
sid, isec->sid, SECCLASS_MSGQ,
MSGQ__CREATE, &ad);
}

static int selinux_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg)
Expand Down Expand Up @@ -6125,18 +6123,16 @@ static int selinux_shm_alloc_security(struct kern_ipc_perm *shp)
struct ipc_security_struct *isec;
struct common_audit_data ad;
u32 sid = current_sid();
int rc;

isec = selinux_ipc(shp);
ipc_init_security(isec, SECCLASS_SHM);

ad.type = LSM_AUDIT_DATA_IPC;
ad.u.ipc_id = shp->key;

rc = avc_has_perm(&selinux_state,
sid, isec->sid, SECCLASS_SHM,
SHM__CREATE, &ad);
return rc;
return avc_has_perm(&selinux_state,
sid, isec->sid, SECCLASS_SHM,
SHM__CREATE, &ad);
}

static int selinux_shm_associate(struct kern_ipc_perm *shp, int shmflg)
Expand Down Expand Up @@ -6210,18 +6206,16 @@ static int selinux_sem_alloc_security(struct kern_ipc_perm *sma)
struct ipc_security_struct *isec;
struct common_audit_data ad;
u32 sid = current_sid();
int rc;

isec = selinux_ipc(sma);
ipc_init_security(isec, SECCLASS_SEM);

ad.type = LSM_AUDIT_DATA_IPC;
ad.u.ipc_id = sma->key;

rc = avc_has_perm(&selinux_state,
sid, isec->sid, SECCLASS_SEM,
SEM__CREATE, &ad);
return rc;
return avc_has_perm(&selinux_state,
sid, isec->sid, SECCLASS_SEM,
SEM__CREATE, &ad);
}

static int selinux_sem_associate(struct kern_ipc_perm *sma, int semflg)
Expand Down

0 comments on commit 09b71ad

Please sign in to comment.