[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220319165159.2170650-1-trix@redhat.com>
Date: Sat, 19 Mar 2022 09:51:59 -0700
From: trix@...hat.com
To: jpoimboe@...hat.com, jikos@...nel.org, mbenes@...e.cz,
pmladek@...e.com, joe.lawrence@...hat.com, nathan@...nel.org,
ndesaulniers@...gle.com
Cc: live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, Tom Rix <trix@...hat.com>
Subject: [PATCH] livepatch: Reorder to use before freeing a pointer
From: Tom Rix <trix@...hat.com>
Clang static analysis reports this issue
livepatch-shadow-fix1.c:113:2: warning: Use of
memory after it is freed
pr_info("%s: dummy @ %p, prevented leak @ %p\n",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The pointer is freed in the previous statement.
Reorder the pr_info to report before the free.
Signed-off-by: Tom Rix <trix@...hat.com>
---
samples/livepatch/livepatch-shadow-fix1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/samples/livepatch/livepatch-shadow-fix1.c b/samples/livepatch/livepatch-shadow-fix1.c
index 918ce17b43fda..6701641bf12d4 100644
--- a/samples/livepatch/livepatch-shadow-fix1.c
+++ b/samples/livepatch/livepatch-shadow-fix1.c
@@ -109,9 +109,9 @@ static void livepatch_fix1_dummy_leak_dtor(void *obj, void *shadow_data)
void *d = obj;
int **shadow_leak = shadow_data;
- kfree(*shadow_leak);
pr_info("%s: dummy @ %p, prevented leak @ %p\n",
__func__, d, *shadow_leak);
+ kfree(*shadow_leak);
}
static void livepatch_fix1_dummy_free(struct dummy *d)
--
2.26.3
Powered by blists - more mailing lists