ipacm: add NULL check on conntrack de-registration am: 17ec1600b8
am: 6bad500db9
Change-Id: I2ba68dc9c1a884ae9d646ba8a20839ff3a50997d
diff --git a/msm8998/ipacm/src/IPACM_ConntrackClient.cpp b/msm8998/ipacm/src/IPACM_ConntrackClient.cpp
index 8cc3407..10154ea 100644
--- a/msm8998/ipacm/src/IPACM_ConntrackClient.cpp
+++ b/msm8998/ipacm/src/IPACM_ConntrackClient.cpp
@@ -598,28 +598,43 @@
IPACMDBG("\n");
+ pClient = IPACM_ConntrackClient::GetInstance();
+ if(pClient == NULL)
+ {
+ IPACMERR("unable to retrieve instance of conntrack client\n");
+ return;
+ }
+
/* destroy the TCP filter.. this will not detach the filter */
- nfct_filter_destroy(pClient->tcp_filter);
- pClient->tcp_filter = NULL;
+ if (pClient->tcp_filter) {
+ nfct_filter_destroy(pClient->tcp_filter);
+ pClient->tcp_filter = NULL;
+ }
/* de-register the callback */
- nfct_callback_unregister(pClient->tcp_hdl);
- /* close the handle */
- nfct_close(pClient->tcp_hdl);
- pClient->tcp_hdl = NULL;
+ if (pClient->tcp_hdl) {
+ nfct_callback_unregister(pClient->tcp_hdl);
+ /* close the handle */
+ nfct_close(pClient->tcp_hdl);
+ pClient->tcp_hdl = NULL;
+ }
/* destroy the filter.. this will not detach the filter */
- nfct_filter_destroy(pClient->udp_filter);
- pClient->udp_filter = NULL;
+ if (pClient->udp_filter) {
+ nfct_filter_destroy(pClient->udp_filter);
+ pClient->udp_filter = NULL;
+ }
/* de-register the callback */
- nfct_callback_unregister(pClient->udp_hdl);
- /* close the handle */
- nfct_close(pClient->udp_hdl);
- pClient->udp_hdl = NULL;
+ if (pClient->udp_hdl) {
+ nfct_callback_unregister(pClient->udp_hdl);
+ /* close the handle */
+ nfct_close(pClient->udp_hdl);
+ pClient->udp_hdl = NULL;
+ }
- pClient->fd_tcp = 0;
- pClient->fd_udp = 0;
+ pClient->fd_tcp = -1;
+ pClient->fd_udp = -1;
return;
}