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