[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7496533e9a84110d4c5862cbcc7afdf72215f0ac.1452105878.git.shuahkh@osg.samsung.com>
Date: Wed, 6 Jan 2016 13:26:54 -0700
From: Shuah Khan <shuahkh@....samsung.com>
To: mchehab@....samsung.com, tiwai@...e.com, clemens@...isch.de,
hans.verkuil@...co.com, laurent.pinchart@...asonboard.com,
sakari.ailus@...ux.intel.com, javier@....samsung.com
Cc: Shuah Khan <shuahkh@....samsung.com>, pawel@...iak.com,
m.szyprowski@...sung.com, kyungmin.park@...sung.com,
perex@...ex.cz, arnd@...db.de, dan.carpenter@...cle.com,
tvboxspy@...il.com, crope@....fi, ruchandani.tina@...il.com,
corbet@....net, chehabrafael@...il.com, k.kozlowski@...sung.com,
stefanr@...6.in-berlin.de, inki.dae@...sung.com,
jh1009.sung@...sung.com, elfring@...rs.sourceforge.net,
prabhakar.csengg@...il.com, sw0312.kim@...sung.com,
p.zabel@...gutronix.de, ricardo.ribalda@...il.com,
labbott@...oraproject.org, pierre-louis.bossart@...ux.intel.com,
ricard.wanderlof@...s.com, julian@...st.de, takamichiho@...il.com,
dominic.sacre@....de, misterpib@...il.com, daniel@...que.org,
gtmkramer@...all.nl, normalperson@...t.net, joe@...po.co.uk,
linuxbugs@...tgam.net, johan@...ud.se,
linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
linux-api@...r.kernel.org, alsa-devel@...a-project.org
Subject: [PATCH 05/31] media: Media Controller fix to not let stream_count go negative
Add a range check to not let the stream_count become negative.
Wthout this check, calls to stop pipeline when there is no active
pipeline will result in stream_count < 0 condition and lock and
preventing link state (activate/deactivate) changes. This will
happen from error leg in start pipeline interface.
Signed-off-by: Shuah Khan <shuahkh@....samsung.com>
---
drivers/media/media-entity.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 6e02d19..78486a9 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -464,9 +464,12 @@ error:
media_entity_graph_walk_start(graph, entity_err);
while ((entity_err = media_entity_graph_walk_next(graph))) {
- entity_err->stream_count--;
- if (entity_err->stream_count == 0)
- entity_err->pipe = NULL;
+ /* don't let the stream_count go negative */
+ if (entity->stream_count > 0) {
+ entity_err->stream_count--;
+ if (entity_err->stream_count == 0)
+ entity_err->pipe = NULL;
+ }
/*
* We haven't increased stream_count further than this
@@ -498,9 +501,12 @@ void media_entity_pipeline_stop(struct media_entity *entity)
media_entity_graph_walk_start(graph, entity);
while ((entity = media_entity_graph_walk_next(graph))) {
- entity->stream_count--;
- if (entity->stream_count == 0)
- entity->pipe = NULL;
+ /* don't let the stream_count go negative */
+ if (entity->stream_count > 0) {
+ entity->stream_count--;
+ if (entity->stream_count == 0)
+ entity->pipe = NULL;
+ }
}
if (!--pipe->streaming_count)
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists