2024-02-20 05:19:17

by Li zeming

[permalink] [raw]
Subject: [PATCH] exec: Remove unnecessary ‘NULL’ values from vma

vma is assigned first, so it does not need to initialize the
assignment.

Signed-off-by: Li zeming <[email protected]>
---
fs/exec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/exec.c b/fs/exec.c
index af4fbb61cd53e..7be0527f5ff25 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -254,7 +254,7 @@ static void flush_arg_page(struct linux_binprm *bprm, unsigned long pos,
static int __bprm_mm_init(struct linux_binprm *bprm)
{
int err;
- struct vm_area_struct *vma = NULL;
+ struct vm_area_struct *vma;
struct mm_struct *mm = bprm->mm;

bprm->vma = vma = vm_area_alloc(mm);
--
2.18.2



2024-02-24 01:04:58

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] exec: Remove unneces sary ‘NULL’ values from vma

On Tue, Feb 20, 2024 at 01:18:30PM +0800, Li zeming wrote:
> vma is assigned first, so it does not need to initialize the
> assignment.

I don't really like removing explicit initializations. They don't cause
any problems and the compiler will remove redundant stores, so there's
no benefit in dropping them.

--
Kees Cook