lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230926173736.1142420-1-visitorckw@gmail.com>
Date:   Wed, 27 Sep 2023 01:37:36 +0800
From:   Kuan-Wei Chiu <visitorckw@...il.com>
To:     daniel.lezcano@...aro.org, rafael@...nel.org
Cc:     amitk@...nel.org, rui.zhang@...el.com, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Kuan-Wei Chiu <visitorckw@...il.com>
Subject: [PATCH v2] tools/thermal: remove unused 'mds' and 'nrhandler' variables

In the previous code, the 'mds' and 'nrhandler' variables were not
utilized in the codebase. Additionally, there was a potential NULL
pointer dereference and memory leak due to improper handling of memory
reallocation failure.

This patch removes the unused 'mds' and 'nrhandler' variables along with
the associated code, addressing the unused variable issue, NULL pointer
dereference issue and the memory leak issue.

Signed-off-by: Kuan-Wei Chiu <visitorckw@...il.com>
---
Changes since v1:
 * Remove the unused 'mds' and 'nrhandler' variables along with the
   associated code.

 tools/thermal/lib/mainloop.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/tools/thermal/lib/mainloop.c b/tools/thermal/lib/mainloop.c
index 94cbbcbd1c14..bf4c1b730d7b 100644
--- a/tools/thermal/lib/mainloop.c
+++ b/tools/thermal/lib/mainloop.c
@@ -9,7 +9,6 @@
 #include "log.h"
 
 static int epfd = -1;
-static unsigned short nrhandler;
 static sig_atomic_t exit_mainloop;
 
 struct mainloop_data {
@@ -18,8 +17,6 @@ struct mainloop_data {
 	int fd;
 };
 
-static struct mainloop_data **mds;
-
 #define MAX_EVENTS 10
 
 int mainloop(unsigned int timeout)
@@ -61,13 +58,6 @@ int mainloop_add(int fd, mainloop_callback_t cb, void *data)
 
 	struct mainloop_data *md;
 
-	if (fd >= nrhandler) {
-		mds = realloc(mds, sizeof(*mds) * (fd + 1));
-		if (!mds)
-			return -1;
-		nrhandler = fd + 1;
-	}
-
 	md = malloc(sizeof(*md));
 	if (!md)
 		return -1;
@@ -76,7 +66,6 @@ int mainloop_add(int fd, mainloop_callback_t cb, void *data)
 	md->cb = cb;
 	md->fd = fd;
 
-	mds[fd] = md;
 	ev.data.ptr = md;
 
 	if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev) < 0) {
@@ -89,14 +78,9 @@ int mainloop_add(int fd, mainloop_callback_t cb, void *data)
 
 int mainloop_del(int fd)
 {
-	if (fd >= nrhandler)
-		return -1;
-
 	if (epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL) < 0)
 		return -1;
 
-	free(mds[fd]);
-
 	return 0;
 }
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ