summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcutils.c
diff options
context:
space:
mode:
authorRuediger Meier2014-03-13 09:20:50 +0100
committerRuediger Meier2014-03-14 00:23:14 +0100
commit3d5fcdb19acfa3f8b2ade005af4f7762e309f88f (patch)
treec8aba52fee12e1527fced51df5ae5250b914b522 /sys-utils/ipcutils.c
parentipcs: fix ipc_sem_get_info fallback case (diff)
downloadkernel-qcow2-util-linux-3d5fcdb19acfa3f8b2ade005af4f7762e309f88f.tar.gz
kernel-qcow2-util-linux-3d5fcdb19acfa3f8b2ade005af4f7762e309f88f.tar.xz
kernel-qcow2-util-linux-3d5fcdb19acfa3f8b2ade005af4f7762e309f88f.zip
ipcs: fix memleak in ipc_*_get_info functions
In case of error (maxid < 0) we do not enter following for loop. It will return 0 and free the structs afterwards because i is still 0. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'sys-utils/ipcutils.c')
-rw-r--r--sys-utils/ipcutils.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/sys-utils/ipcutils.c b/sys-utils/ipcutils.c
index ef856f5b7..c45162ad8 100644
--- a/sys-utils/ipcutils.c
+++ b/sys-utils/ipcutils.c
@@ -155,8 +155,6 @@ int ipc_shm_get_info(int id, struct shm_data **shmds)
/* Fallback; /proc or /sys file(s) missing. */
shm_fallback:
maxid = shmctl(0, SHM_INFO, (struct shmid_ds *) &dummy);
- if (maxid < 0)
- return 0;
for (int j = 0; j <= maxid; j++) {
int shmid;
@@ -297,8 +295,6 @@ int ipc_sem_get_info(int id, struct sem_data **semds)
sem_fallback:
arg.array = (ushort *) (void *)&dummy;
maxid = semctl(0, 0, SEM_INFO, arg);
- if (maxid < 0)
- return 0;
for (int j = 0; j <= maxid; j++) {
int semid;
@@ -415,8 +411,6 @@ int ipc_msg_get_info(int id, struct msg_data **msgds)
/* Fallback; /proc or /sys file(s) missing. */
msg_fallback:
maxid = msgctl(0, MSG_INFO, &dummy);
- if (maxid < 0)
- return 0;
for (int j = 0; j <= maxid; j++) {
int msgid;