From 71d1ddbe77047a0a6d8fe4cac38db114977fb709 Mon Sep 17 00:00:00 2001 From: Srikanth Marepalli Date: Thu, 23 Aug 2018 19:15:57 +0530 Subject: [PATCH] qsap: Add NULL check for soc & msg allocations in qsap_get_mode Add appropriate checks to avoid NULL pointer dereferencing. Change-Id: I9b96eeb1cf3b860416c950b5c689dc5858e194c6 CRs-Fixed: 2300013 --- softap/sdk/qsap_api.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/softap/sdk/qsap_api.c b/softap/sdk/qsap_api.c index 4bf4658..4c48cb2 100644 --- a/softap/sdk/qsap_api.c +++ b/softap/sdk/qsap_api.c @@ -1349,6 +1349,12 @@ int qsap_get_mode(s32 *pmode) //allocate socket sk = nl_socket_alloc(); + //return if socket allocation fails + if(sk == NULL){ + ALOGE( "socket allocation failure"); + return ret; + } + //connect to generic netlink if (genl_connect(sk)) { ALOGE( "Netlink socket Connection failure"); @@ -1366,6 +1372,12 @@ int qsap_get_mode(s32 *pmode) //allocate a message msg = nlmsg_alloc(); + //return if message allocation fails + if(msg == NULL){ + ALOGE( "message allocation failure"); + goto nla_put_failure; + } + // setup the message genlmsg_put(msg, 0, 0, nl80211_id, 0, 0, NL80211_CMD_GET_INTERFACE, 0);