kernel/media-cec-Fix-runtime-BUG-when-CONFIG_RC_CORE-CEC_CAP_RC.patch
2017-04-28 12:24:30 +01:00

46 lines
1.7 KiB
Diff

From patchwork Tue Apr 4 12:32:19 2017
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [2/2, media] cec: Fix runtime BUG when (CONFIG_RC_CORE && !CEC_CAP_RC)
From: Lee Jones <lee.jones@linaro.org>
X-Patchwork-Id: 9661691
Message-Id: <20170404123219.22040-2-lee.jones@linaro.org>
To: hans.verkuil@cisco.com,
mchehab@kernel.org
Cc: benjamin.gaignard@st.com, patrice.chotard@st.com,
linux-kernel@vger.kernel.org, kernel@stlinux.com,
Lee Jones <lee.jones@linaro.org>, linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org
Date: Tue, 4 Apr 2017 13:32:19 +0100
Currently when the RC Core is enabled (reachable) core code located
in cec_register_adapter() attempts to populate the RC structure with
a pointer to the 'parent' passed in by the caller.
Unfortunately if the caller did not specify RC capibility when calling
cec_allocate_adapter(), then there will be no RC structure to populate.
This causes a "NULL pointer dereference" error.
Fixes: f51e80804f0 ("[media] cec: pass parent device in register(), not allocate()")
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/media/cec/cec-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index 06a312c..d64937b 100644
--- a/drivers/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -286,8 +286,8 @@ int cec_register_adapter(struct cec_adapter *adap,
adap->devnode.dev.parent = parent;
#if IS_REACHABLE(CONFIG_RC_CORE)
- adap->rc->dev.parent = parent;
if (adap->capabilities & CEC_CAP_RC) {
+ adap->rc->dev.parent = parent;
res = rc_register_device(adap->rc);
if (res) {