Skip to content

Commit

Permalink
ASoC: Intel: Add NULL checks for the stream pointer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jie Yang authored and Mark Brown committed Jan 7, 2015
1 parent d83901e commit f81677b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions sound/soc/intel/sst-haswell-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,11 @@ int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
struct sst_dsp *sst = hsw->dsp;
unsigned long flags;

if (!stream) {
dev_warn(hsw->dev, "warning: stream is NULL, no stream to free, ignore it.\n");
return 0;
}

/* dont free DSP streams that are not commited */
if (!stream->commited)
goto out;
Expand Down Expand Up @@ -1415,6 +1420,16 @@ int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
u32 header;
int ret;

if (!stream) {
dev_warn(hsw->dev, "warning: stream is NULL, no stream to commit, ignore it.\n");
return 0;
}

if (stream->commited) {
dev_warn(hsw->dev, "warning: stream is already committed, ignore it.\n");
return 0;
}

trace_ipc_request("stream alloc", stream->host_id);

header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM);
Expand Down Expand Up @@ -1519,6 +1534,11 @@ int sst_hsw_stream_pause(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
{
int ret;

if (!stream) {
dev_warn(hsw->dev, "warning: stream is NULL, no stream to pause, ignore it.\n");
return 0;
}

trace_ipc_request("stream pause", stream->reply.stream_hw_id);

ret = sst_hsw_stream_operations(hsw, IPC_STR_PAUSE,
Expand All @@ -1535,6 +1555,11 @@ int sst_hsw_stream_resume(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
{
int ret;

if (!stream) {
dev_warn(hsw->dev, "warning: stream is NULL, no stream to resume, ignore it.\n");
return 0;
}

trace_ipc_request("stream resume", stream->reply.stream_hw_id);

ret = sst_hsw_stream_operations(hsw, IPC_STR_RESUME,
Expand All @@ -1550,6 +1575,11 @@ int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
{
int ret, tries = 10;

if (!stream) {
dev_warn(hsw->dev, "warning: stream is NULL, no stream to reset, ignore it.\n");
return 0;
}

/* dont reset streams that are not commited */
if (!stream->commited)
return 0;
Expand Down

0 comments on commit f81677b

Please sign in to comment.