All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: iwd@lists.01.org
Subject: [PATCH 1/5] resolve: Exit methods if resolve is NULL
Date: Mon, 21 Sep 2020 15:52:05 +0200	[thread overview]
Message-ID: <20200921135209.595749-1-andrew.zaborowski@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2205 bytes --]

If no resolve method gets configured, the resolve_new() call in
netconfig returns NULL.  To avoid adding checks netconfig every time
netconfig->resolve is used, add these checks directly in the resolve_*
methods.  Fixes the following crash:

src/netconfig.c:netconfig_destroy()
Aborting (signal 11) [/path/iwd]
++++++++ backtrace ++++++++
 #0  0x7f3ee427f210 in /lib/x86_64-linux-gnu/libc.so.6
 #1  0x43bcf4 in resolve_revert() at src/resolve.c:85
 #2  0x43ae2d in netconfig_destroy() at src/netconfig.c:1206
 #3  0x440cd6 in p2p_connection_reset() at src/p2p.c:662
 #4  0x47200f in process_unicast() at ell/genl.c:979
 #5  0x46e807 in io_callback() at ell/io.c:126
 #6  0x46d9bd in l_main_iterate() at ell/main.c:467 (discriminator 2)
 #7  0x46da8c in l_main_run() at ell/main.c:516
 #8  0x4047c6 in main() at src/main.c:506
 #9  0x7f3ee42600b3 in /lib/x86_64-linux-gnu/libc.so.6
+++++++++++++++++++++++++++
---
 src/resolve.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/resolve.c b/src/resolve.c
index 066e4c87..07eee5a9 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -60,7 +60,7 @@ static inline void _resolve_init(struct resolve *resolve, uint32_t ifindex,
 
 void resolve_add_dns(struct resolve *resolve, uint8_t type, char **dns_list)
 {
-	if (!dns_list || !*dns_list)
+	if (!resolve || !dns_list || !*dns_list)
 		return;
 
 	if (!resolve->ops->add_dns)
@@ -71,7 +71,7 @@ void resolve_add_dns(struct resolve *resolve, uint8_t type, char **dns_list)
 
 void resolve_add_domain_name(struct resolve *resolve, const char *domain_name)
 {
-	if (!domain_name)
+	if (!resolve || !domain_name)
 		return;
 
 	if (!resolve->ops->add_domain_name)
@@ -82,7 +82,7 @@ void resolve_add_domain_name(struct resolve *resolve, const char *domain_name)
 
 void resolve_revert(struct resolve *resolve)
 {
-	if (!resolve->ops->revert)
+	if (!resolve || !resolve->ops->revert)
 		return;
 
 	resolve->ops->revert(resolve);
@@ -90,6 +90,9 @@ void resolve_revert(struct resolve *resolve)
 
 void resolve_free(struct resolve *resolve)
 {
+	if (!resolve)
+		return;
+
 	resolve->ops->destroy(resolve);
 }
 
-- 
2.25.1

             reply	other threads:[~2020-09-21 13:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21 13:52 Andrew Zaborowski [this message]
2020-09-21 13:52 ` [PATCH 2/5] p2p: Free peer->wfd in p2p_peer_free Andrew Zaborowski
2020-09-21 13:52 ` [PATCH 3/5] p2p: Free parsed frame data in p2p_go_negotiation_confirm_cb Andrew Zaborowski
2020-09-21 13:52 ` [PATCH 4/5] p2p: Free response frame payloads Andrew Zaborowski
2020-09-21 13:52 ` [PATCH 5/5] ap: Use frame-xchg when sending frames Andrew Zaborowski
2020-09-21 19:04 [PATCH 1/5] resolve: Exit methods if resolve is NULL Andrew Zaborowski
2020-09-22  3:13 ` Denis Kenzior
2020-09-22  4:18   ` Andrew Zaborowski
2020-09-22 14:11     ` Denis Kenzior
2020-09-22 14:28       ` Andrew Zaborowski
2020-09-22 14:34         ` Denis Kenzior
2020-09-22 21:34           ` Andrew Zaborowski
2020-09-23  1:48             ` Denis Kenzior

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=20200921135209.595749-1-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=iwd@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.