From: Romain Naour <romain.naour@gmail.com>
To: util-linux@vger.kernel.org
Cc: Romain Naour <romain.naour@gmail.com>
Subject: [PATCH] lsipc: don't free shm data if no shm id is found
Date: Tue, 22 Mar 2016 22:19:54 +0100 [thread overview]
Message-ID: <1458681594-2085-1-git-send-email-romain.naour@gmail.com> (raw)
There is a segfault in do_shm_global() when ipc_shm_get_info() return 0 and
ipc_shm_free_info() is called.
When no shm id is found, the memory allocated in shmds by ipc_shm_get_info() is
already free when ipc_shm_free_info() is called.
Move ipc_shm_free_info(shmds) inside the if statement where at least one shm id
is found.
Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
sys-utils/lsipc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c
index 938728a..195ee15 100644
--- a/sys-utils/lsipc.c
+++ b/sys-utils/lsipc.c
@@ -1071,14 +1071,13 @@ static void do_shm_global(struct libscols_table *tb)
++nsegs;
sum_segsz += shmdsp->shm_segsz;
}
+ ipc_shm_free_info(shmds);
}
global_set_data(tb, "SHMMNI", _("Shared memory segments"), nsegs, lim.shmmni, 1);
global_set_data(tb, "SHMALL", _("Shared memory pages"), sum_segsz / getpagesize(), lim.shmall, 1);
global_set_data(tb, "SHMMAX", _("Max size of shared memory segment (bytes)"), 0, lim.shmmax, 0);
global_set_data(tb, "SHMMIN", _("Min size of shared memory segment (bytes)"), 0, lim.shmmin, 0);
-
- ipc_shm_free_info(shmds);
}
int main(int argc, char *argv[])
--
2.5.0
next reply other threads:[~2016-03-22 21:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 21:19 Romain Naour [this message]
2016-03-23 10:08 ` [PATCH] lsipc: don't free shm data if no shm id is found Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458681594-2085-1-git-send-email-romain.naour@gmail.com \
--to=romain.naour@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox