[PATCH v4 2/8] lockdown: remove useless decrement operation
Cai Xinchen
caixinchen1 at huawei.com
Mon Nov 30 08:29:08 UTC 2026
From: Kalevi Kolttonen <kalevi at kolttonen.fi>
The length of the written state is only used to strip the trailing
newline; it is never read afterwards, so decrementing it while
stripping the newline serves no purpose. Drop the decrement, and with
it the braces around the now single-statement if.
No functional change.
Tested-by: Guicai Ma <maguicai at kylinos.cn>
Reviewed-by: Nicolas Bouchinet <nicolas.bouchinet at oss.cyber.gouv.fr>
Signed-off-by: Kalevi Kolttonen <kalevi at kolttonen.fi>
---
security/lockdown/lockdown.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
index 263dcc80d839..8648508d49b2 100644
--- a/security/lockdown/lockdown.c
+++ b/security/lockdown/lockdown.c
@@ -130,10 +130,8 @@ static ssize_t lockdown_write(struct file *file, const char __user *buf,
return PTR_ERR(state);
len = strlen(state);
- if (len && state[len-1] == '\n') {
+ if (len && state[len-1] == '\n')
state[len-1] = '\0';
- len--;
- }
for (i = 0; i < ARRAY_SIZE(lockdown_levels); i++) {
enum lockdown_reason level = lockdown_levels[i];
--
2.18.0.huawei.25
More information about the Linux-security-module-archive
mailing list