From patchwork Tue Apr 4 12:32:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 96721 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp171271qgd; Tue, 4 Apr 2017 05:32:34 -0700 (PDT) X-Received: by 10.98.84.194 with SMTP id i185mr22508961pfb.234.1491309153963; Tue, 04 Apr 2017 05:32:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u24si17395908pfa.270.2017.04.04.05.32.33; Tue, 04 Apr 2017 05:32:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754244AbdDDMca (ORCPT + 25 others); Tue, 4 Apr 2017 08:32:30 -0400 Received: from mail-wr0-f176.google.com ([209.85.128.176]:35849 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753993AbdDDMc1 (ORCPT ); Tue, 4 Apr 2017 08:32:27 -0400 Received: by mail-wr0-f176.google.com with SMTP id w11so211135546wrc.3 for ; Tue, 04 Apr 2017 05:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9geFZIs2Nppnd+oxhYCTo9FNicTZWV2bBzjs36VWvKw=; b=UJ1cxFfewkjSmmszaF4xKNOxy4Nrxa96KPmw4TibG9mouJdhyjoaWswnyURTLmE69a tVev7waKrl2/5ndZow1Dd+PP/a/undfHmuVQPJXl4UonsY43eY56zI3WOAyU72c1mfAs QVwEJpYJxoMAiIxDraziVefwdXjBAHeb7/0Zw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9geFZIs2Nppnd+oxhYCTo9FNicTZWV2bBzjs36VWvKw=; b=Rr5bOm1xux6bKXlw0xTm53UU5EXDYCg4cIOZ8N+70sc37QwKwXFXeZ1M1ts6GFDjgJ ppJ8cx2FaLotvJdSA4HbgYlRJb4MTwIttg+NyY0i+y9wSfLkW2KwZf39D5x3XglAe//Z HGNiMVRBmseh6w06cAGfpaOh/pk3f7WOYwJppNbqv5Gy1ubK29XHIpKWXteSh4oi7vHJ ES0rNzoF7SI1fXHTLvNPZYfkvn+dt8QIMZTLgNt/wgOCqox8wBIr83yiSliumMfrWJF6 DKcOAsjIINKXdhCQwJaGc5lAjwFqkvAWuo0wX9MlAomlf6PzXrUCpKUaznoPZ5B5mfdv +gUw== X-Gm-Message-State: AFeK/H1e7TQ2/nFN7QJEwtTHsr+Rl6LxicraKlHyyNTL0SO7L7sfIkQTsPD58/AScBVDA9Je X-Received: by 10.223.130.36 with SMTP id 33mr20523156wrb.150.1491309145286; Tue, 04 Apr 2017 05:32:25 -0700 (PDT) Received: from localhost.localdomain ([2.31.167.174]) by smtp.gmail.com with ESMTPSA id 75sm21479249wmp.2.2017.04.04.05.32.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 05:32:24 -0700 (PDT) From: Lee Jones To: hans.verkuil@cisco.com, mchehab@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@stlinux.com, patrice.chotard@st.com, linux-media@vger.kernel.org, benjamin.gaignard@st.com, Lee Jones Subject: [PATCH 1/2] [media] cec: Move capability check inside #if Date: Tue, 4 Apr 2017 13:32:18 +0100 Message-Id: <20170404123219.22040-1-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_RC_CORE is not enabled then none of the RC code will be executed anyway, so we're placing the capability check inside the Signed-off-by: Lee Jones --- drivers/media/cec/cec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c index 37217e2..06a312c 100644 --- a/drivers/media/cec/cec-core.c +++ b/drivers/media/cec/cec-core.c @@ -234,10 +234,10 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, return ERR_PTR(res); } +#if IS_REACHABLE(CONFIG_RC_CORE) if (!(caps & CEC_CAP_RC)) return adap; -#if IS_REACHABLE(CONFIG_RC_CORE) /* Prepare the RC input device */ adap->rc = rc_allocate_device(RC_DRIVER_SCANCODE); if (!adap->rc) { From patchwork Tue Apr 4 12:32:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 96722 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp171274qgd; Tue, 4 Apr 2017 05:32:34 -0700 (PDT) X-Received: by 10.99.253.5 with SMTP id d5mr23140269pgh.47.1491309154352; Tue, 04 Apr 2017 05:32:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u24si17395908pfa.270.2017.04.04.05.32.34; Tue, 04 Apr 2017 05:32:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754278AbdDDMcb (ORCPT + 25 others); Tue, 4 Apr 2017 08:32:31 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:33589 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754181AbdDDMc2 (ORCPT ); Tue, 4 Apr 2017 08:32:28 -0400 Received: by mail-wr0-f179.google.com with SMTP id w43so212220998wrb.0 for ; Tue, 04 Apr 2017 05:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K+S1hDM3WJymnv7EMKcB5eZV6MFyszw7GY8hBApHglM=; b=kAU1LFC+QlOWhk4d7wUJBdTxtG1DFvZOh5hN75IxrK9NIviiFCLk+ggpXVVMJBHCAW C7iqTecblqSzNPlhR0GBqj7VHMCs7bY9Kpve7ei/jF1jme0v/iVJN4xDjKpERmN2hwRe LL64pBAVNLYXbYJn/FBpopKJALVceaoxaSdDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K+S1hDM3WJymnv7EMKcB5eZV6MFyszw7GY8hBApHglM=; b=KC2itN51b5qb6cCWusMelXTlhu+e0id+8VQJApaOeK+9IIEWLCP48EWXTsnhHqFW3S C1nn/qYmN4MDoa6QWSUxWumGyUCdfX3MY0dbSRbjy44cF64B/+nSZhqvjH8vQQg/EHYZ 8fP/jbt5Vb6MFDimXuPmqTC+6YQTscCaaIwzGyIpRCyhEjnn6wf9Q6erB6372v01KT84 MhaFEAELBfW2ehCUNSjnYxYV3+0+aZ/WEIJiEzMwWIGtmI+h/VKxLc/aoygUdswF3c+L 0ZE0m2BG8IQFsCaYuyyjcUvQw7lPntrhcVmfqhL+IKmZesfMR857HoRk29hVvDyQ4KWS m3ZA== X-Gm-Message-State: AFeK/H1W1v6WNXM64RJv/AbRFXVVsNzLVAze2+o7DwZuaJOR0cgr8d6fp7oys1KOqDlxO6uL X-Received: by 10.223.142.18 with SMTP id n18mr20288862wrb.188.1491309146366; Tue, 04 Apr 2017 05:32:26 -0700 (PDT) Received: from localhost.localdomain ([2.31.167.174]) by smtp.gmail.com with ESMTPSA id 75sm21479249wmp.2.2017.04.04.05.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 05:32:25 -0700 (PDT) From: Lee Jones To: hans.verkuil@cisco.com, mchehab@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@stlinux.com, patrice.chotard@st.com, linux-media@vger.kernel.org, benjamin.gaignard@st.com, Lee Jones Subject: [PATCH 2/2] [media] cec: Fix runtime BUG when (CONFIG_RC_CORE && !CEC_CAP_RC) Date: Tue, 4 Apr 2017 13:32:19 +0100 Message-Id: <20170404123219.22040-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404123219.22040-1-lee.jones@linaro.org> References: <20170404123219.22040-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/media/cec/cec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 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) {