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 06246C33CB3 for ; Thu, 30 Jan 2020 18:42:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8FD02082E for ; Thu, 30 Jan 2020 18:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409758; bh=W7nfk0mbH79NWZr6d75aI0ZGr3L4fvnrkEYSC93NwW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MgdQvPDje5/dwESIVDbCLz4ncHC7omwDZZprDHRl5oLms1vYVagdUzdKROJ++MOnt QvagPIO+Tjou3ql8K9XkGGkafkMEggvp64jxma1bIjmT2vdG+fK8YAG1jNyZna+z3R G08kP+0sLu3TstVzGVvWH72/AnedR3rgHZdV9Vg0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730427AbgA3Smi (ORCPT ); Thu, 30 Jan 2020 13:42:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:50872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730409AbgA3Smd (ORCPT ); Thu, 30 Jan 2020 13:42:33 -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 6B0892082E; Thu, 30 Jan 2020 18:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409752; bh=W7nfk0mbH79NWZr6d75aI0ZGr3L4fvnrkEYSC93NwW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xyq24+kP+nIuizI7WH9IUTtxSqmzMrSkQ06BXc7gS5vs6xgDL6c2mt3B6FxbL01KO YG/5bZMyQqNmpnog6wowpZK8AapSq4MxqrX/4GeD4OIQdXmu0Pg8LD7xiyjX3lni/M txYjjCCQLwY8F2R8B4Z9KUO4FmdT3AiwvqwPslwU= 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.4 020/110] component: do not dereference opaque pointer in debugfs Date: Thu, 30 Jan 2020 19:37:56 +0100 Message-Id: <20200130183617.297000748@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@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);