Skip to content

Commit 47c82aa

Browse files
Hans Verkuilmchehab
authored andcommitted
media: cec: core: avoid recursive cec_claim_log_addrs
Keep track if cec_claim_log_addrs() is running, and return -EBUSY if it is when calling CEC_ADAP_S_LOG_ADDRS. This prevents a case where cec_claim_log_addrs() could be called while it was still in progress. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reported-by: Yang, Chenyuan <cy54@illinois.edu> Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/ Fixes: ca68438 ("[media] cec: add HDMI CEC framework (api)") Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 42bcaac commit 47c82aa

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/media/cec/core/cec-adap.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,12 @@ static int cec_config_thread_func(void *arg)
15741574
*/
15751575
static void cec_claim_log_addrs(struct cec_adapter *adap, bool block)
15761576
{
1577-
if (WARN_ON(adap->is_configuring || adap->is_configured))
1577+
if (WARN_ON(adap->is_claiming_log_addrs ||
1578+
adap->is_configuring || adap->is_configured))
15781579
return;
15791580

1581+
adap->is_claiming_log_addrs = true;
1582+
15801583
init_completion(&adap->config_completion);
15811584

15821585
/* Ready to kick off the thread */
@@ -1591,6 +1594,7 @@ static void cec_claim_log_addrs(struct cec_adapter *adap, bool block)
15911594
wait_for_completion(&adap->config_completion);
15921595
mutex_lock(&adap->lock);
15931596
}
1597+
adap->is_claiming_log_addrs = false;
15941598
}
15951599

15961600
/*

drivers/media/cec/core/cec-api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh,
178178
CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU |
179179
CEC_LOG_ADDRS_FL_CDC_ONLY;
180180
mutex_lock(&adap->lock);
181-
if (!adap->is_configuring &&
181+
if (!adap->is_claiming_log_addrs && !adap->is_configuring &&
182182
(!log_addrs.num_log_addrs || !adap->is_configured) &&
183183
!cec_is_busy(adap, fh)) {
184184
err = __cec_s_log_addrs(adap, &log_addrs, block);

include/media/cec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ struct cec_adapter {
258258
u16 phys_addr;
259259
bool needs_hpd;
260260
bool is_enabled;
261+
bool is_claiming_log_addrs;
261262
bool is_configuring;
262263
bool must_reconfigure;
263264
bool is_configured;

0 commit comments

Comments
 (0)