selinux: Fix Kernel panic due to NULL pointer dereference

Below Kernel panic is observed due to race condition, where
sock_has_perm called in a thread and is trying to access sksec->sid
without checking sksec. Just before that, sk->sk_security was set
to NULL by selinux_sk_free_security through sk_free in other thread.

31704.949269:   <3> IPv4: Attempt to release alive inet socket dd81b200
31704.959049:   <1> Unable to handle kernel NULL pointer dereference at \
                        virtual address 00000000
31704.983562:   <1> pgd = c6b74000
31704.985248:   <1> [00000000] *pgd=00000000
31704.996591:   <0> Internal error: Oops: 5 [#1] PREEMPT SMP ARM
31705.001016:   <6> Modules linked in: adsprpc [last unloaded: wlan]
31705.006659:   <6> CPU: 1    Tainted: G           O  \
                        (3.4.0-g837ab9b-00003-g6bcd9c6 #1)
31705.014042:   <6> PC is at sock_has_perm+0x58/0xd4
31705.018292:   <6> LR is at sock_has_perm+0x58/0xd4
31705.022546:   <6> pc : [<c0341e8c>]    lr : [<c0341e8c>]    \
                                                  psr: 60000013
31705.022549:   <6> sp : dda27f00  ip : 00000000  fp : 5f36fc84
31705.034002:   <6> r10: 00004000  r9 : 0000009d  r8 : e8c2b700
31705.039211:   <6> r7 : dda27f24  r6 : dd81b200  r5 : 00000000  \
                                                  r4 : 00000000
31705.045721:   <6> r3 : 00000000  r2 : dda27ef8  r1 : 00000000  \
                                                  r0 : dda27f54
31705.052232:   <6> Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM \
                        Segment user
31705.059349:   <6> Control: 10c5787d  Table: 10d7406a  DAC: 00000015
.
.
.
.
31705.697816:   <6> [<c0341e8c>] (sock_has_perm+0x58/0xd4) from \
                    [<c033ed10>] (security_socket_getsockopt+0x14/0x1c)
31705.707534:   <6> [<c033ed10>] (security_socket_getsockopt+0x14/0x1c) \
                           from [<c0745c18>] (sys_getsockopt+0x34/0xa8)
31705.717343:   <6> [<c0745c18>] (sys_getsockopt+0x34/0xa8) from \
                    [<c0106140>] (ret_fast_syscall+0x0/0x30)
31705.726193:   <0> Code: e59832e8 e5933058 e5939004 ebfac736 (e5953000)
31705.732635:   <4> ---[ end trace 22889004dafd87bd ]---

Change-Id: I79c3fb525f35ea2494d53788788cd71a38a32d6b
Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
Signed-off-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
[SCSI] async: introduce 'async_domain' type

This is in preparation for teaching async_synchronize_full() to sync all
pending async work, and not just on the async_running domain.  This
conversion is functionally equivalent, just embedding the existing list
in a new async_domain type.

The .registered attribute is used in a later patch to distinguish
between domains that want to be flushed by async_synchronize_full()
versus those that only expect async_synchronize_{full|cookie}_domain to
be used for flushing.

Change-Id: I9ab0a06052d05da47c0a3d7f3ebc55e3968aa3cc
[jejb: add async.h to scsi_priv.h for struct async_domain]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Tested-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
ASoC: Cold start latency reduction

This patch parallelizes FE (front end) and BE (back end)
when playback/capture path is set up. FE's and BE's which can
be parallelized should be indicated in corresponding machine file.
All the operations can be started asynchronously provided the usecase
supports asynchronous operation.
Parallelizing reduces the startup latency as both FE and BE opeations
run in parallel.

Change-Id: I9eeaf500b6d90d4def0adc1bdd6c219e49f676c7
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
ASoC: msm8974: Machine driver async ops change

Asoc framework supports parallelization of operations
which reduces the startup latency. Machine driver will
specify which usecases support parallelization. This
change updates the machine driver to enable the parallelization.

Signed-off-by: Anish Kumar <kanish@codeaurora.org>
Change-Id: I5b26bfb6f8b7a3c128b4c853400b10e70ecccb25
ASoC: msm: qdsp6v2: move hw_params into prepare

Asoc framework supports parallelization of operations
which reduces the startup latency.
Moving hw_params into prepare further reduces this start
up latency.

Change-Id: If38df2ba22daa94afdff8a7cd90263f4a1fafae7
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
ASoC: msm: Add MP2 decode support in compress driver

Add MP2 decoder support to ALSA compressed driver. It
allows user-space application to play MP2 audio data through
QDSP6.

Change-Id: I44c35ebe40a361c70bfde3caf88f4f4c6bb457e4
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
ASoC: msm: Add support for WMA DSP decode

WMA V9 and WMA Pro tunnel-mode supports are added to
compressed driver. It allows user-space application to
decode WMA V9 and WMA Pro audio stream through QDSP6.

Change-Id: I99407d00b618a627e6d762be9abea4abd2410b8b
Signed-off-by: Manish Dewangan <manish@codeaurora.org>
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
ASoC: msm: Fix wma pro block alignment parameter

The current code assigns and sends the wrong block
alignment information to the adsp because of which wma pro
playback fails. The fix assigns the correct block alignment
information for wma pro.

Change-Id: Ide475bbb8f98cd0201c2f8635a3ed831cd460194
Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
ASoC: qdsp6: Add MP2 decoder format support

New ASM message format is added to support tunnel-mode MP2
decoder through QDSP6.

Change-Id: Icc25aae0945ac6cd3ba9d6eeacd8528dee952ae3
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
ASoC: msm: qdsp6v2: Update pcm media format block to use correct stream id

Repeat mode is not working in pcm offload path. When two streams
are used in a single session pcm format block should be sent
specific to each stream. Data sent on stream 2 is ignored by DSP
because pcm format block is always sent on stream 1. Fix is to
update pcm media format block to use correct stream id before
data is sent to DSP.

CRs-Fixed: 673510
Change-Id: Id9369f9927fbd301ed6020ea9e35942b54305610
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
msm: qdsp: fix aac encoder configuration validation

Unsupported encoder configuration was getting forwarded to
DSP causing encode failure at latter stage.
Corrected encoder validation logic which would throw
error for unsupported configuration values and would use
default conf in such cases, preventing failure at latter
stage where error from dsp cannot be handled gracefully.
Also updated userspace to driver format mapping.

CRs-Fixed: 621150
Change-Id: Id049425ac12fa076ad2891f563da67a103630383
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
ASoC: compress: fix the target not going to TCXO shutdown

The error code propagated from the flush cmd in the trigger stop
is causing the error in the state of the soc compress framework.
This hinders in closing the BE connected to the FE.
If the AFE is not closed it prevents the target to go into TCXO
shutdown.
Fixed by removing the error handling of the flush command in the
trigger stop, since failure in flush doesn't signify the
failure in the stop command.

CRs-Fixed: 687111
Change-Id: I8f6e2bfbd0e59516ede2359dda4cedf027948a72
Signed-off-by: Aviral Gupta <aviralg@codeaurora.org>
Merge branch 'cm-11.0' into kk_mkt