[PATCH 2/8] vpn: Check also vpn-driver to avoid NULL ptr dereference.

Jussi Laakkonen <[email protected]> Thu, 10 Apr 2025 18:58:40 +0300
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
Found with Clang analyzer.
---
 vpn/plugins/vpn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index cb0d304b..fc2a0e74 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -3,6 +3,7 @@
  *  ConnMan VPN daemon
  *
  *  Copyright (C) 2007-2013  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2025  Jolla Mobile Ltd
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -162,7 +163,7 @@ vpn_exit:
 		if (name)
 			vpn_data = g_hash_table_lookup(driver_hash, name);

-		if (vpn_data &&
+		if (vpn_data && vpn_data->vpn_driver &&
 				vpn_data->vpn_driver->error_code)
 			ret = vpn_data->vpn_driver->error_code(provider,
 					exit_code);
--
2.39.5