From patchwork Sun Feb 27 13:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12761766 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 C9BD3C433F5 for ; Sun, 27 Feb 2022 13:54:25 +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=lJAbWA4e0QrAPNBdzoCvzKgye2NJBXLXbqpuD/ok3xU=; b=QaLqcjC61/7zw5 YlSuSpChR2OzR4c3mdv1PseSfHmFbDaVYD/7Usi5WmURkHHu5pfQ4nJuFSNoXLu+jIw2anjCyukJ8 IYpKZe4Qktuv8Xrohqsq8XUbdyUr9RUCIkECF1VugAPNPhwIudSCUfSC2pCIw8uz8baukrmAvzBAf EuAnrg3ksfxSXJGjgrjUee5t7QAtE2pWQxpfmNpRCOT8Vf/YPxV5LJEX7DHDa8lYhU3t1ffrwyp3H cUQvNSrb/e1uYAkM+GiskXzviTrUtes9dTaHj2y+O2HFNFdBUDXf/reL5f/3k4ipE8M0PvqBgWVg5 IMojWUq2hKYl/mq0FORA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOJyt-009Hsu-So; Sun, 27 Feb 2022 13:53:00 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOJye-009HmS-PS for linux-arm-kernel@lists.infradead.org; Sun, 27 Feb 2022 13:52:46 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1C5C84030D for ; Sun, 27 Feb 2022 13:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645969963; bh=beBPqukoSZCIAAv6gBbQLkWehzWMNdiQtzWlJ1M8u3o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Q0yBogF5EI/STkEA/utUdvdzoZQv3aIdqXs5dw92ptnuSLJ63I4KlAJFeNMiwuVCj I3gTmZIvYZOcKsOvq5CV8ldWxrKm0z4zEPLZAvT/X6zIRLHF08lc1Uv3o4b2FqOdkn eAlT+RDtY55EiYwHv/sdHdxMt9nPcC7f6adHMJ7TgdSD4ot+jO55arzz/PdnDjxvGf 3XHaUNAPZ8dijFUoTe8hdIRzAtjELnK3aBPbEfYw3Yn/Akl/QnIRuRZZyIL7dl5Lr9 XkmMi6vc+J/xqTjbFHlPtigzmR558EadvKilX9Nch4LsiqjB79wZHPa67yqWftbtyA Cicp83FpizRPg== Received: by mail-ej1-f70.google.com with SMTP id hc39-20020a17090716a700b006ce88cf89dfso4366553ejc.10 for ; Sun, 27 Feb 2022 05:52:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=beBPqukoSZCIAAv6gBbQLkWehzWMNdiQtzWlJ1M8u3o=; b=GUzmXoU1esQ+arRYMyX0Y/WC2h9TVNndyn39oB4LCduUajF3wkC/Ho8HLBk9wJcDCH wveECIKWsOb8rtB32KW2G9ssOoqboPFTtaKUdTIKjOuHa7E2seTSgblLGVOZC4q3rqKs z5MgUmyVDkuAWxRJ+imMJLhH/kTQKMmibz4/TRgsbKVdCtSMUxxN0TwbNR+w3e9eDiNZ xiEysJjolmqj66quJzMaT081idjiSsYLfcqGedJ7DW06CQBh3+aI3ZNog2+9rv/BMinE hXngZ71/z4/YwWyCWvbfatH85vinrJpPfzWrqJ87PZ6IQEsXddOIxTO+n+AE179myCDU dm7A== X-Gm-Message-State: AOAM531/V3R1lPhMB5j1uYdPfEbEvVvYZ9LFJY34v9doXxLJY4LOVrMw PpJFnfMqRi5Z8mSyNjfTiTJgRcOdGvpVOnEgYyqzgoGjuXU1EqOpl961ehwGO6SjPyuZmcb+Aka +jDK2428XZ1DWjTUFqWbfO0QVgAjPdu76kuskzFvp13Qm+SVNdZRU X-Received: by 2002:a05:6402:50d4:b0:413:2a27:6b56 with SMTP id h20-20020a05640250d400b004132a276b56mr15602869edb.228.1645969951020; Sun, 27 Feb 2022 05:52:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMchrZ/z130i6cHNU0MCCxUHxTeH+44NX7i1itMtaADlHbWFNXu2qsfZhNkboTf+/7DLObYg== X-Received: by 2002:a05:6402:50d4:b0:413:2a27:6b56 with SMTP id h20-20020a05640250d400b004132a276b56mr15602826edb.228.1645969950731; Sun, 27 Feb 2022 05:52:30 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id r22-20020a17090638d600b006d584aaa9c9sm3393333ejd.133.2022.02.27.05.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 05:52:30 -0800 (PST) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Stuart Yoder , Laurentiu Tudor , Abel Vesa , Shawn Guo , Sascha Hauer , Fabio Estevam , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Bjorn Helgaas , Bjorn Andersson , Mathieu Poirier , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Andy Gross , Srinivas Kandagatla , Mark Brown , "Michael S. Tsirkin" , Jason Wang , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-spi@vger.kernel.org, virtualization@lists.linux-foundation.org, Linus Torvalds Cc: Rasmus Villemoes , Krzysztof Kozlowski Subject: [PATCH v3 00/11] Fix broken usage of driver_override (and kfree of static memory) Date: Sun, 27 Feb 2022 14:52:03 +0100 Message-Id: <20220227135214.145599-1-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_055244_992349_85632DC3 X-CRM114-Status: GOOD ( 15.47 ) 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 Hi, This is a continuation of my old patchset from 2019. [1] Back then, few drivers set driver_override wrong. I fixed Exynos in a different way after discussions. QCOM NGD was not fixed and a new user appeared - IMX SCU. It seems "char *" in driver_override looks too consty, so we tend to make a mistake of storing there string literals. Changes since latest v2 ======================= 1. Make all driver_override fields as "const char *", just like SPI and VDPA. (Mark) 2. Move "count" check to the new helper and add "count" argument. (Michael) 3. Fix typos in docs, patch subject. Extend doc. (Michael, Bjorn) 4. Compare pointers to reduce number of string readings in the helper. 5. Fix clk-imx return value. Changes since latest v1 (not the old 2019 solution): ==================================================== https://lore.kernel.org/all/708eabb1-7b35-d525-d4c3-451d4a3de84f@rasmusvillemoes.dk/ 1. Add helper for setting driver_override. 2. Use the helper. Dependencies (and stable): ========================== 1. All patches, including last three fixes, depend on the first patch introducing the helper. 2. The last three commits - fixes - are probably not backportable directly, because of this dependency. I don't know how to express this dependency here, since stable-kernel-rules.rst mentions only commits as possible dependencies. [1] https://lore.kernel.org/all/1550484960-2392-3-git-send-email-krzk@kernel.org/ Best regards, Krzysztof Krzysztof Kozlowski (11): driver: platform: Add helper for safer setting of driver_override amba: Use driver_set_override() instead of open-coding fsl-mc: Use driver_set_override() instead of open-coding hv: Use driver_set_override() instead of open-coding PCI: Use driver_set_override() instead of open-coding s390: cio: Use driver_set_override() instead of open-coding spi: Use helper for safer setting of driver_override vdpa: Use helper for safer setting of driver_override clk: imx: scu: Fix kfree() of static memory on setting driver_override slimbus: qcom-ngd: Fix kfree() of static memory on setting driver_override rpmsg: Fix kfree() of static memory on setting driver_override drivers/amba/bus.c | 28 +++--------------- drivers/base/driver.c | 51 +++++++++++++++++++++++++++++++++ drivers/base/platform.c | 28 +++--------------- drivers/bus/fsl-mc/fsl-mc-bus.c | 25 +++------------- drivers/clk/imx/clk-scu.c | 7 ++++- drivers/hv/vmbus_drv.c | 28 +++--------------- drivers/pci/pci-sysfs.c | 28 +++--------------- drivers/rpmsg/rpmsg_core.c | 3 +- drivers/rpmsg/rpmsg_internal.h | 13 +++++++-- drivers/rpmsg/rpmsg_ns.c | 14 +++++++-- drivers/s390/cio/cio.h | 7 ++++- drivers/s390/cio/css.c | 28 +++--------------- drivers/slimbus/qcom-ngd-ctrl.c | 13 ++++++++- drivers/spi/spi.c | 26 +++-------------- drivers/vdpa/vdpa.c | 29 +++---------------- include/linux/amba/bus.h | 7 ++++- include/linux/device/driver.h | 2 ++ include/linux/fsl/mc.h | 6 ++-- include/linux/hyperv.h | 7 ++++- include/linux/pci.h | 7 ++++- include/linux/platform_device.h | 7 ++++- include/linux/rpmsg.h | 6 ++-- include/linux/spi/spi.h | 2 ++ include/linux/vdpa.h | 4 ++- 24 files changed, 171 insertions(+), 205 deletions(-)