Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2100740ybl; Thu, 30 Jan 2020 11:21:59 -0800 (PST) X-Google-Smtp-Source: APXvYqyQx1Nbf+M2O8Nu85iRbkbAKvcqJVwIH8BMiUZWFIybQWMUP7ZPxSnCIChObZoZE9Xb4NUs X-Received: by 2002:aca:1c01:: with SMTP id c1mr4027653oic.18.1580412119293; Thu, 30 Jan 2020 11:21:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580412119; cv=none; d=google.com; s=arc-20160816; b=pS1lcNp5rz1Lxgy+uClwQkIPibV7Zu2a9Geo8+EPQSlfMFA3tAS8yGa/aNFlGi44ky c0TqRxEmCoohcO/alLsW8OznKoGZCOU9l53LrqzB/CjY2SBtww4P6aG+nuFURrmI8qam Rcu6vOT8ez4EKiiGLigmjSoUaHnFCepqK9MOlk3MeC8dHxkLB/nEVk7Ahm4rn5kAAWTs 8Z8mieJnfwCPXnNMosk7b6mUKvfOXfrZbXkxni1EcfqYdaAJOmEoQ9A/Yz6QoQEPeOjv uCi8cXlGe5SRkLbA285EyrrPJjHHpoy3gmKiwX6M+tLYgZQKZjjcdwQ/7nSrfU0LK5x6 QkYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wCbHbIgiFDz9YxCLs+gzuU/FDSfu7lV40LUYfuHyPK0=; b=KKfX++dnldD0dWX2V+DY6exzi3lH9mfo5jtAfYMDeiTRtRHtfHBamnneQ7PZjhIG6+ EaEfndlrc9E5QFk6zznulXtfdaBMw8Xwnt+odWwmqwfoKS/vl3rt54Hcc1v04o2gclZv bQUx9npevjtJc1bZcsmMbG6NhswljcIMughlHyL1klSXr+AgPVNzOeAb/+u6paPWOxV8 Rj1sa/yHCuYQFRP6zHkuNiZmIG+5jFggdUC2eIV4MGN2rNdfLG3BSyKJBHWdxqMFgMeG qw8Wb051Cav3/fjpSdxcY3sNXGz4sai2ORNz47roqZpACHHtsmPRA+pM1ZTm9gHpRGXC 3F4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pZP3lozF; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si3554957otk.154.2020.01.30.11.21.47; Thu, 30 Jan 2020 11:21:59 -0800 (PST) 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=@kernel.org header.s=default header.b=pZP3lozF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731430AbgA3StW (ORCPT + 99 others); Thu, 30 Jan 2020 13:49:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:59760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbgA3Ssj (ORCPT ); Thu, 30 Jan 2020 13:48:39 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B074220CC7; Thu, 30 Jan 2020 18:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580410119; bh=AgpXlJbli/9L7qbemL8DxcROTQAomKZ18xUHp2up7GA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZP3lozFw1V27qz3PdSH3i4lA/OKZ2J5sgYJIEyykUOqit27cgjmr9ix9g/9krcPO H38zymSLv/be2BEfCAG4Nn1axE9p5eWTR9PRvYjOhrbqW2f+f6dV3HHHMjxbWtT+UJ Tz29UkaJNp2gccCmp3/BNfjzLg9+0tWsBJGUtiTA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lubomir Rintel , Arnaud Pouliquen Subject: [PATCH 4.19 14/55] component: do not dereference opaque pointer in debugfs Date: Thu, 30 Jan 2020 19:38:55 +0100 Message-Id: <20200130183611.446214525@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.563083888@linuxfoundation.org> References: <20200130183608.563083888@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lubomir Rintel commit ef9ffc1e5f1ac73ecd2fb3b70db2a3b2472ff2f7 upstream. The match data does not have to be a struct device pointer, and indeed very often is not. Attempt to treat it as such easily results in a crash. For the components that are not registered, we don't know which device is missing. Once it it is there, we can use the struct component to get the device and whether it's bound or not. Fixes: 59e73854b5fd ('component: add debugfs support') Signed-off-by: Lubomir Rintel Cc: stable Cc: Arnaud Pouliquen Link: https://lore.kernel.org/r/20191118115431.63626-1-lkundrak@v3.sk Signed-off-by: Greg Kroah-Hartman --- drivers/base/component.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -74,11 +74,11 @@ static int component_devices_show(struct seq_printf(s, "%-40s %20s\n", "device name", "status"); seq_puts(s, "-------------------------------------------------------------\n"); for (i = 0; i < match->num; i++) { - struct device *d = (struct device *)match->compare[i].data; + struct component *component = match->compare[i].component; - seq_printf(s, "%-40s %20s\n", dev_name(d), - match->compare[i].component ? - "registered" : "not registered"); + seq_printf(s, "%-40s %20s\n", + component ? dev_name(component->dev) : "(unknown)", + component ? (component->bound ? "bound" : "not bound") : "not registered"); } mutex_unlock(&component_mutex);