From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 043F6C2D0DB for ; Thu, 30 Jan 2020 18:54:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCC862082E for ; Thu, 30 Jan 2020 18:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580410467; bh=W7nfk0mbH79NWZr6d75aI0ZGr3L4fvnrkEYSC93NwW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lkrlpiBUkNyivNKe82IOmnuF28THr0b8k4ZPvh5De0ouhEqg5sxWuLPhyY5xAmy08 +vBtR7KbwYHtonoLnLfJtYGHPpQc7UgcogndWU4gm/S7EAJ4RvUT+1L7+3Lc/W+Rwm /gucQVhHRSet25rflgdvZZjTve85znJeIL9MwiLM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgA3SkV (ORCPT ); Thu, 30 Jan 2020 13:40:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:47746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729899AbgA3SkP (ORCPT ); Thu, 30 Jan 2020 13:40:15 -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 A6ECC2082E; Thu, 30 Jan 2020 18:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409614; bh=W7nfk0mbH79NWZr6d75aI0ZGr3L4fvnrkEYSC93NwW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PgqqrsMgyjIfUXkoPmtnpI7jOB13rOzdiNqZZkhAP0WKghZ+DcDIiBuUVkaYEx9CS NtH7CBmztuQNB1xUzID/VFcdB+Zg7S43ZGz6xSVUn7d7LOGqQfqneuOg9JolbsFEgf utNjtpi52ehmbAz7dYHqic7y1a1DB+S8dAFDe7U0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lubomir Rintel , Arnaud Pouliquen Subject: [PATCH 5.5 20/56] component: do not dereference opaque pointer in debugfs Date: Thu, 30 Jan 2020 19:38:37 +0100 Message-Id: <20200130183612.904859905@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.849023566@linuxfoundation.org> References: <20200130183608.849023566@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 @@ -102,11 +102,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);