aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJie Yang <yang.jie@intel.com>2015-01-07 09:07:05 -0500
committerMark Brown <broonie@kernel.org>2015-01-07 12:32:19 -0500
commitf81677b4d1acc0e7cd74a43bfd9900d9512b90ae (patch)
tree14c2e50b3e7cbda84e929cde8502506405a7a882 /sound
parentd83901e82010cb3b25e69a9bbe991e9fbd940725 (diff)
ASoC: Intel: Add NULL checks for the stream pointer
We should not send IPC stream commands to FW when the stream is NULL, dereference the NULL pointer may also occur without precheck. Here add NULL pointer checks for these stream APIs. Signed-off-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/intel/sst-haswell-ipc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c
index 3f8c48231364..5bf14040c24a 100644
--- a/sound/soc/intel/sst-haswell-ipc.c
+++ b/sound/soc/intel/sst-haswell-ipc.c
@@ -1228,6 +1228,11 @@ int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1228 struct sst_dsp *sst = hsw->dsp; 1228 struct sst_dsp *sst = hsw->dsp;
1229 unsigned long flags; 1229 unsigned long flags;
1230 1230
1231 if (!stream) {
1232 dev_warn(hsw->dev, "warning: stream is NULL, no stream to free, ignore it.\n");
1233 return 0;
1234 }
1235
1231 /* dont free DSP streams that are not commited */ 1236 /* dont free DSP streams that are not commited */
1232 if (!stream->commited) 1237 if (!stream->commited)
1233 goto out; 1238 goto out;
@@ -1415,6 +1420,16 @@ int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1415 u32 header; 1420 u32 header;
1416 int ret; 1421 int ret;
1417 1422
1423 if (!stream) {
1424 dev_warn(hsw->dev, "warning: stream is NULL, no stream to commit, ignore it.\n");
1425 return 0;
1426 }
1427
1428 if (stream->commited) {
1429 dev_warn(hsw->dev, "warning: stream is already committed, ignore it.\n");
1430 return 0;
1431 }
1432
1418 trace_ipc_request("stream alloc", stream->host_id); 1433 trace_ipc_request("stream alloc", stream->host_id);
1419 1434
1420 header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM); 1435 header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM);
@@ -1519,6 +1534,11 @@ int sst_hsw_stream_pause(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
1519{ 1534{
1520 int ret; 1535 int ret;
1521 1536
1537 if (!stream) {
1538 dev_warn(hsw->dev, "warning: stream is NULL, no stream to pause, ignore it.\n");
1539 return 0;
1540 }
1541
1522 trace_ipc_request("stream pause", stream->reply.stream_hw_id); 1542 trace_ipc_request("stream pause", stream->reply.stream_hw_id);
1523 1543
1524 ret = sst_hsw_stream_operations(hsw, IPC_STR_PAUSE, 1544 ret = sst_hsw_stream_operations(hsw, IPC_STR_PAUSE,
@@ -1535,6 +1555,11 @@ int sst_hsw_stream_resume(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
1535{ 1555{
1536 int ret; 1556 int ret;
1537 1557
1558 if (!stream) {
1559 dev_warn(hsw->dev, "warning: stream is NULL, no stream to resume, ignore it.\n");
1560 return 0;
1561 }
1562
1538 trace_ipc_request("stream resume", stream->reply.stream_hw_id); 1563 trace_ipc_request("stream resume", stream->reply.stream_hw_id);
1539 1564
1540 ret = sst_hsw_stream_operations(hsw, IPC_STR_RESUME, 1565 ret = sst_hsw_stream_operations(hsw, IPC_STR_RESUME,
@@ -1550,6 +1575,11 @@ int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1550{ 1575{
1551 int ret, tries = 10; 1576 int ret, tries = 10;
1552 1577
1578 if (!stream) {
1579 dev_warn(hsw->dev, "warning: stream is NULL, no stream to reset, ignore it.\n");
1580 return 0;
1581 }
1582
1553 /* dont reset streams that are not commited */ 1583 /* dont reset streams that are not commited */
1554 if (!stream->commited) 1584 if (!stream->commited)
1555 return 0; 1585 return 0;