From patchwork Fri Apr 19 14:26:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13636456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D12BAC4345F for ; Fri, 19 Apr 2024 14:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lnHjNoPyl2Oifm/jPI7LjGoRaM017igK9RMnNfom1EU=; b=UNryMEZerawE4K TUBn0jiQsIdLiwt+zOps4fQ+ZOGwnKl4SQTXFIYaBP0Msvg0WzfMQZFvsOBSzB0nOyO1B94A9n2kq 5iGOHF9sDLYMIEMwi89b326/XAnBqyq6Nh8T1rGZPX/9FufVWnruMD6mFrrBRKV96V2WbkSZ3lMxb +xADZ3JQlrKaJQeSRQ79jFxJzML3opE0dQgvvv/bl1XpXtozc0RdO+lQY1a2Gl6dIFUYB+5UY/9R9 8wDzGNP938/bizmrdfFNF5pJxJnmcUFG/E5P1KIejhmBDord+t1DEv726yL8K1qw2XNC72F/da0/O QrKzcJEdQrWka7YwoiZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxpD2-00000005yAW-0d2P; Fri, 19 Apr 2024 14:27:24 +0000 Received: from mout.gmx.net ([212.227.17.22]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxpCw-00000005y5W-2Q1F for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 14:27:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1713536831; x=1714141631; i=wahrenst@gmx.net; bh=AaNkgdxXm7U/qu3aiwXm8r8W25b/1Mh+5OB/yHfIrYw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=Z9hoEG279KeXe4mJaR/9x8eEfdbAcMv/R/Ag7394siNwIfJutd+Xw0SRvtv+RloH YzwF5JbWKp7zmTxBMJHRxuJ4JmjnCKDswQgESZVAxWepx4paeKlq/dsYXpcDYvVC+ f58Dto1dqc1B2+fYZQIAf55ynPeVaubFk0xwbeLiNmy8Dq4l3fstdaQVlJJ4NttlI v2wRscJqAqSdE59/s9D7CRJIXJwbhYRgwQC+duqpO/L0E5W7pDyf0Grh+yxfhxVA0 z0JigHojbedntYn6UFD17s8TiN3hweXQcVxsX2zvO/H4a/bWfmAsTb4FHKVYupLXl xH7rKYRJIExgquu85A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N6KYb-1smhks1289-016fvd; Fri, 19 Apr 2024 16:27:11 +0200 From: Stefan Wahren To: Greg Kroah-Hartman , Florian Fainelli Cc: Umang Jain , Laurent Pinchart , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH] staging: vc04_services: vchiq_arm: Fix NULL ptr dereferences Date: Fri, 19 Apr 2024 16:26:50 +0200 Message-Id: <20240419142650.206583-1-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:qiDh/T0QRN67ss/fyMYZjpEHGCQioC0vEyHBzmu+MQMOEgqAQlR 2+9lheMfxkEKE3ghb4NOH8Ke2wjMB95+bVt8vSWU3SDM2JE5+NMG0fog7EK5v/2U1YpbVCw +ISG+WjMY3F4c3B370tczg6XzOUXoLmS0ArWzHW/NibJAdFUdCYKPcQYAtHkY2D4typ1QlH te/9vhxeC3t4wJCFG1xEA== UI-OutboundReport: notjunk:1;M01:P0:Pbz3FSd140M=;PH1rIeWVrfD4psubD39IkfcQ0O5 BYTWLVpWhsf6+CljTo6rUkWKCNZWdc8Ho6D3nNb8YjPW0aZrk/lxS62JNUyKdC8DPI4oknqri zaGuh6JHE6LMHqXndEeLkKXCnROfaaS+kgZpcyGZtf7u+FBUPoArxgEvkmgJl55dXCGWzWLRI W9BH13hjEpbK20KiTRwSM4h4C1V/8UgflC3IpH8TVhZOoHzfkeQtV+PJ/mr2WzxdStkBSPPBO mb1nMky9UJ4hNhmRvu5QbTejubik8CLg6jMmoIgnpKiuyVoTSFQ90zgkxAXDzQKbxwFElxD9R cQZqFZjNDAMgyd5PGVF9K2yNwI+Jj4/RII8h6u3s62KMTaFYZ+LOtslYq6gw5sOYffDaixqOr KBU0d9j8K8Do3OrPuyIXjWAzk7o1aKsjTnp9u+HHYcBOya8ZCVtT+wOQhDr95uUlIrTU3kDai fih9MXck9Ny0sVk1b78y+sFVRioW761lv5YXV4TPJzIL6Z4Ujp2Sz46YoUD23CxHL/w+4kCtF og9jBwmCntNZi0w3N+Hk+bEXYVC23nP30VhZLpgFY3VpBA78qCt0CF8HBXFaQgjl7E+Fa6aLn Dv+WSG0Y/mblQFp3+EET7+kE3CPwZdOoxyW0/mFBwaHZO8KbJFc7Cz9KwYfvaqeGl3Jgo1YjS smE9xnnHmS4XNXD/Zdp3OHEpS9HUFjKUvRvdYjzlFnJ/11FIjx/kG3pcaKz5jPRmW7c5kq2EI JgF5e9XqXVLgXfQHk9teV4EKvyyoxqLrDjnoc7XIlXEbrYLXjXMPeIovPCioFJTGl7aFUvCwp A1w5pU+sjQek4d+eC5EcAka4cgE+slaCbXVBSGZyt8jT8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_072719_038548_97A19A3D X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The commit 8c9753f63905 ("staging: vc04_services: vchiq_arm: Drop g_cache_line_size") introduced NULL pointer dereferences by messing up usage of device driver data. But the real issue here is the mixed usage of platform and device driver data. So fix this by switching completely to device driver data. Fixes: 8c9753f63905 ("staging: vc04_services: vchiq_arm: Drop g_cache_line_size") Signed-off-by: Stefan Wahren --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.34.1 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 502ddc0f6e46..3b032d987f0c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -257,7 +257,7 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf, if (count >= INT_MAX - PAGE_SIZE) return NULL; - drv_mgmt = dev_get_drvdata(instance->state->dev->parent); + drv_mgmt = dev_get_drvdata(instance->state->dev); if (buf) offset = (uintptr_t)buf & (PAGE_SIZE - 1); @@ -436,7 +436,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, actual); - drv_mgmt = dev_get_drvdata(instance->state->dev->parent); + drv_mgmt = dev_get_drvdata(instance->state->dev); /* * NOTE: dma_unmap_sg must be called before the @@ -497,7 +497,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) { struct device *dev = &pdev->dev; - struct vchiq_drv_mgmt *drv_mgmt = platform_get_drvdata(pdev); + struct vchiq_drv_mgmt *drv_mgmt = dev_get_drvdata(dev); struct rpi_firmware *fw = drv_mgmt->fw; struct vchiq_slot_zero *vchiq_slot_zero; void *slot_mem; @@ -1753,7 +1753,7 @@ static int vchiq_probe(struct platform_device *pdev) return -EPROBE_DEFER; mgmt->info = info; - platform_set_drvdata(pdev, mgmt); + dev_set_drvdata(&pdev->dev, mgmt); err = vchiq_platform_init(pdev, &mgmt->state); if (err)