diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2017-11-02 21:50:09 +0100 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2017-11-02 21:50:09 +0100 |
commit | 451d65660b62aa23e9d3083174153e9a5a068c5f (patch) | |
tree | a3c7d5764cff67e2be4e175f1bccd6292e0f618b | |
parent | e3e66b496be0c4abe4fa74569691ea2fb2624b86 (diff) |
Fix FD leaking on Alsa Control
-rw-r--r-- | alsa-binding/Alsa-RegEvt.c | 5 | ||||
-rw-r--r-- | alsa-binding/Alsa-SetGet.c | 4 | ||||
-rw-r--r-- | alsa-binding/Alsa-Ucm.c | 2 | ||||
-rw-r--r-- | nbproject/configurations.xml | 88 |
4 files changed, 44 insertions, 55 deletions
diff --git a/alsa-binding/Alsa-RegEvt.c b/alsa-binding/Alsa-RegEvt.c index 41db207..035806e 100644 --- a/alsa-binding/Alsa-RegEvt.c +++ b/alsa-binding/Alsa-RegEvt.c @@ -235,8 +235,9 @@ PUBLIC void alsaEvtSubcribe(afb_req request) { // increase usage count and return success sndHandles[idx].ucount++; + snd_ctl_close(ctlDev); afb_req_success(request, NULL, NULL); - return; + // use OnErrorExit OnErrorExit: if (ctlDev) snd_ctl_close(ctlDev); @@ -277,6 +278,8 @@ STATIC json_object *alsaProbeCardId(afb_req request) { shortname = snd_ctl_card_info_get_name(cardinfo); longname = snd_ctl_card_info_get_longname(cardinfo); + snd_ctl_close(ctlDev); + // check if short|long name match if (!strcmp(sndname, ctlName)) break; if (!strcmp(sndname, shortname)) break; diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c index 2083a53..1b7d4a8 100644 --- a/alsa-binding/Alsa-SetGet.c +++ b/alsa-binding/Alsa-SetGet.c @@ -655,7 +655,7 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) { const char *warmsg = NULL; int err = 0, status = 0, done; unsigned int ctlCount; - snd_ctl_t *ctlDev; + snd_ctl_t *ctlDev=NULL; snd_ctl_elem_list_t *ctlList; queryValuesT queryValues; json_object *queryJ, *numidsJ, *sndctls; @@ -799,8 +799,10 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) { // send response+warning if any afb_req_success(request, sndctls, warmsg); snd_ctl_elem_list_clear(ctlList); + // use OnErrorExit OnErrorExit: + if (ctlDev) snd_ctl_close(ctlDev); return; } diff --git a/alsa-binding/Alsa-Ucm.c b/alsa-binding/Alsa-Ucm.c index 0bfffc9..d608e61 100644 --- a/alsa-binding/Alsa-Ucm.c +++ b/alsa-binding/Alsa-Ucm.c @@ -52,7 +52,7 @@ static ucmHandleT ucmHandles[MAX_SND_CARD]; // Cache opened UCM handles STATIC int alsaUseCaseOpen(struct afb_req request, queryValuesT *queryValues, int allowNewMgr) { - snd_ctl_t *ctlDev; + snd_ctl_t *ctlDev=NULL; snd_ctl_card_info_t *cardinfo; snd_use_case_mgr_t *ucmHandle; const char *cardName; diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 78905c4..85f3fef 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -464,81 +464,57 @@ </cTool> </item> <item path="alsa-binding/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - <incDir> - <pElem>../../../opt/include/afb</pElem> - <pElem>alsa-binding</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> - </incDir> + <cTool flags="0"> </cTool> </item> <item path="alsa-binding/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3"> <cTool flags="0"> + </cTool> + </item> + <item path="alsa-binding/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="alsa-binding/Alsa-SetGet.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="alsa-hook/PolicyAlsaHook.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> <incDir> <pElem>/usr/include/json-c</pElem> <pElem>../../../opt/include</pElem> <pElem>/usr/include/p11-kit-1</pElem> <pElem>../../../opt/include/alsa</pElem> - <pElem>afb-utilities</pElem> - <pElem>build/alsa-binding</pElem> + <pElem>build/alsa-hook</pElem> </incDir> <preprocessorList> <Elem>CONTROL_MAXPATH_LEN=255</Elem> <Elem>MAX_LINEAR_DB_SCALE=24</Elem> <Elem>MAX_SND_CARD=16</Elem> <Elem>NATIVE_LINUX</Elem> + <Elem>PIC</Elem> <Elem>TLV_BYTE_SIZE=256</Elem> - <Elem>alsa_4a_EXPORTS</Elem> + <Elem>policy_alsa_hook_EXPORTS</Elem> </preprocessorList> </cTool> </item> - <item path="alsa-binding/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - <incDir> - <pElem>../../../opt/include/afb</pElem> - <pElem>alsa-binding</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> - </incDir> - </cTool> - </item> - <item path="alsa-binding/Alsa-SetGet.c" ex="false" tool="0" flavor2="3"> + <item path="alsa-hook/PolicyHookTcp.c" ex="false" tool="0" flavor2="3"> <cTool flags="2"> <incDir> - <pElem>../../../opt/include/afb</pElem> - <pElem>alsa-binding</pElem> + <pElem>alsa-hook</pElem> <pElem>../../../opt/include/alsa</pElem> <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> - </incDir> - </cTool> - </item> - <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - <incDir> <pElem>../../../opt/include/afb</pElem> - <pElem>alsa-binding</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>/usr/include/json-c</pElem> <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> + <pElem>build/alsa-hook</pElem> </incDir> </cTool> </item> - <item path="alsa-hook/PolicyAlsaHook.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - </cTool> - </item> - <item path="alsa-hook/PolicyHookTcp.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - </cTool> - </item> <folder path="0/Audio-Common"> <cTool> <incDir> @@ -766,16 +742,24 @@ </preprocessorList> </cTool> </folder> - <folder path="0/alsa-hook"> + <folder path="0/alsa-binding"> <cTool> <incDir> - <pElem>alsa-hook</pElem> - <pElem>../../../opt/include/alsa</pElem> <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include/afb</pElem> <pElem>../../../opt/include</pElem> - <pElem>build/alsa-hook</pElem> + <pElem>/usr/include/p11-kit-1</pElem> + <pElem>../../../opt/include/alsa</pElem> + <pElem>afb-utilities</pElem> + <pElem>build/alsa-binding</pElem> </incDir> + <preprocessorList> + <Elem>CONTROL_MAXPATH_LEN=255</Elem> + <Elem>MAX_LINEAR_DB_SCALE=24</Elem> + <Elem>MAX_SND_CARD=16</Elem> + <Elem>NATIVE_LINUX</Elem> + <Elem>TLV_BYTE_SIZE=256</Elem> + <Elem>alsa_4a_EXPORTS</Elem> + </preprocessorList> </cTool> </folder> </conf> |