OSDN Git Service

pcm: dshare - fix shared memory pointer check
authorVanitha Channaiah <vanitha.channaiah@in.bosch.com>
Sun, 21 Mar 2021 11:00:48 +0000 (16:30 +0530)
committerJaroslav Kysela <perex@perex.cz>
Tue, 13 Apr 2021 16:21:53 +0000 (18:21 +0200)
commit446777c67ea730cdb31cb8c6f22f220dece629e5
treed401d1f5563467704fa6994ee5f43482d47f2db4
parentd18ebb79d75bbc22d5685cfb12e66c0402950e05
pcm: dshare - fix shared memory pointer check

Currently shared memory pointer is initialized to 0 and set to -1
in some, but not in all error paths.
In cleanup path of open the shm pointer is only compared to be non-NULL
before dereferencing it which leads to SEGFAULT in case it was set to -1.

This patch initializes pointer to -1 to have a unique identification
for invalid pointer and also checks for pointer being not -1 on
access in cleanup path.

Signed-off-by: Vanitha Channaiah <vanitha.channaiah@in.bosch.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_dshare.c