ASoC: wcd9xxx: Add check for NULL pointer and buffer overflow

Current code has possible scenarios where NULL pointer
could be dereferenced or an out-of-bound index of array
could be accessed. The change checks the pointer for NULL
before they are dereferenced and checks for buffer overflows
to ensure out of bound indexes of arrays are not
accessed.

Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
mfd: wcd9xxx_irq: Fix the condition to lock/unlock sleep

When codec raises interrupt and the system is suspended, the driver
waits for parent to resume. Fix the condition in wait_for_event to
prevent checking against stale value of suspend state during wait.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>