diff mbox series

[next] security: remove redundant assignment to variable rc

Message ID 20241112124532.468198-1-colin.i.king@gmail.com (mailing list archive)
State New
Headers show
Series [next] security: remove redundant assignment to variable rc | expand

Commit Message

Colin Ian King Nov. 12, 2024, 12:45 p.m. UTC
In the case where rc is equal to EOPNOTSUPP it is being reassigned a
new value of zero that is never read. The following continue statement
loops back to the next iteration of the lsm_for_each_hook loop and
rc is being re-assigned a new value from the call to getselfattr.
The assignment is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 security/security.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Serge E. Hallyn Nov. 12, 2024, 1:32 p.m. UTC | #1
On Tue, Nov 12, 2024 at 12:45:32PM +0000, Colin Ian King wrote:
> In the case where rc is equal to EOPNOTSUPP it is being reassigned a
> new value of zero that is never read. The following continue statement
> loops back to the next iteration of the lsm_for_each_hook loop and
> rc is being re-assigned a new value from the call to getselfattr.
> The assignment is redundant and can be removed.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

Reviewed-by: Serge Hallyn <serge@hallyn.com>

(long as it doesn't go to stable :)

> ---
>  security/security.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/security/security.c b/security/security.c
> index 09664e09fec9..6147f27ea92a 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -4139,10 +4139,8 @@ int security_getselfattr(unsigned int attr, struct lsm_ctx __user *uctx,
>  		if (base)
>  			uctx = (struct lsm_ctx __user *)(base + total);
>  		rc = scall->hl->hook.getselfattr(attr, uctx, &entrysize, flags);
> -		if (rc == -EOPNOTSUPP) {
> -			rc = 0;
> +		if (rc == -EOPNOTSUPP)
>  			continue;
> -		}
>  		if (rc == -E2BIG) {
>  			rc = 0;
>  			left = 0;
> -- 
> 2.39.5
Dan Carpenter Nov. 12, 2024, 2 p.m. UTC | #2
On Tue, Nov 12, 2024 at 07:32:24AM -0600, Serge E. Hallyn wrote:
> On Tue, Nov 12, 2024 at 12:45:32PM +0000, Colin Ian King wrote:
> > In the case where rc is equal to EOPNOTSUPP it is being reassigned a
> > new value of zero that is never read. The following continue statement
> > loops back to the next iteration of the lsm_for_each_hook loop and
> > rc is being re-assigned a new value from the call to getselfattr.
> > The assignment is redundant and can be removed.
> > 
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> 
> Reviewed-by: Serge Hallyn <serge@hallyn.com>
> 
> (long as it doesn't go to stable :)
> 

There is a tag for fixes which would break stable.

Cc: <stable+noautosel@kernel.org> # reason goes here, and must be present

But this isn't a fix and it wouldn't break stable so probably that's not
appropriate.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/security/security.c b/security/security.c
index 09664e09fec9..6147f27ea92a 100644
--- a/security/security.c
+++ b/security/security.c
@@ -4139,10 +4139,8 @@  int security_getselfattr(unsigned int attr, struct lsm_ctx __user *uctx,
 		if (base)
 			uctx = (struct lsm_ctx __user *)(base + total);
 		rc = scall->hl->hook.getselfattr(attr, uctx, &entrysize, flags);
-		if (rc == -EOPNOTSUPP) {
-			rc = 0;
+		if (rc == -EOPNOTSUPP)
 			continue;
-		}
 		if (rc == -E2BIG) {
 			rc = 0;
 			left = 0;