From patchwork Sat Mar 12 13:28:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12778828 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 6004BC433F5 for ; Sat, 12 Mar 2022 13:30:54 +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=yjLRiLb50VRuovE41K3HO6MZqfSBueyWBD/PW2zUWYg=; b=BQj74kLtQFCYe0 rVM/kBYTNoUtwCInas/zHysX1lEHEptivUPVqEaHsZ0u2SLrPX2AkQUnhomciPpQjgNrTUHQQpdXi A/tJLOZg/BNIUs9jUCxUYJsaFkSnR7xwp+urx73YJP1iXiCLTMzNtVgCWwpviMlfFqDzotSifhl/m IyySnMTeZAxYDLvT8c/O2ELuSl+Hk4Lq/mhdbFor4s6+xXhujfrMzQmE14HJBVZ1wpeX7GSU8+p9p AwBuiHicxE8fsIeIPOmMO1KXVVrW/8MLpX8lOn6P9HZ+UNIYMrna+n9H2LeMqCx7J7KEj2XeWBBL0 jmvF/J1Uyavb6FLy5ZGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nT1oM-001LZG-Go; Sat, 12 Mar 2022 13:29:34 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nT1o8-001LTi-P6 for linux-arm-kernel@lists.infradead.org; Sat, 12 Mar 2022 13:29:22 +0000 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (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-0.canonical.com (Postfix) with ESMTPS id 022183F4BC for ; Sat, 12 Mar 2022 13:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1647091754; bh=OCrj2Lr7nKg3/D4n6AH2mK+/SAYpiHPGeQpPG1FkFdg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=wGSnEqAgjHrDfvY7OzkWEWtQb/612fnlsOvlWmaAjYkT9PzOj0BTAHOilqNTXxAKT 4014KhJzvuqJ7H+VKrfrPSLZEuMpAlmXMvZJE16BZafTlnH0MVnjG81EvK5geWY73y sYaJbr127WhQIt6eBwQbPh4Vyp3a4QHl+reo+PasrQ9ltRLQR8/BRNO+eEAnzpJxU7 2aD3pxOeyinORmunyP3i73v+Q39kNJNBtSXXmbOkolD5gjcIdA6XdfNtWq5QEG2vbw LdqfeGxeeC5CLrJSuyiqY+8h+A5zo2UWSXCp5ZjN4OBkziBIVXsrEB7+6LKXydGYID ybosZQT9iob8g== Received: by mail-wm1-f71.google.com with SMTP id z9-20020a7bc7c9000000b00389bd375677so4386922wmk.4 for ; Sat, 12 Mar 2022 05:29:13 -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=OCrj2Lr7nKg3/D4n6AH2mK+/SAYpiHPGeQpPG1FkFdg=; b=SL46yFXNVEuNeM4hZewJBwf5fwfS5HXU595jDh5WLkY5CLiN59lw30Uo1aJki5uvaj xF/BPxcZIWHdM+AucAOwHQHI+QSe2JsOPSkrfn6rEwb3QtdKi348YdUPZk4mCyINo4qr jpmyVBYzbHmNanHu/7swxuJf68I+aOKq30gY/8ZR0CTLE9yTCqCCBzwXU/KBKIvk5DXZ PWJDD5wifwkRlZTes75TAkKAVaAo6hoZp3yX4IMoUoaG59YqK8zcFn6HVi6B66vP3lFD dbk1T6RP9cNfiRHqys4m+8gznuu1jGH3EAnKoGk89aggj3aYzLIv7nlRAHQb5HeyhO3d 2/Qw== X-Gm-Message-State: AOAM530iB9sAcgS3vxRjX6iaSz19wo7f0rZYoP3lfAb4nDKFBgJ+/sJn tO27aJ8RxLGtygL5s43LVTyI1GaznbXXb8mks9vNpQIMC0Q3xbQeg0ng3kPmnsR9xn54YEqv7fh x3ia0mlLRRTvi+yIKWMX2u/6x6p1mv6keGWYQEbkSZGPGx85A3r52 X-Received: by 2002:a5d:4dca:0:b0:1f0:2543:e10e with SMTP id f10-20020a5d4dca000000b001f02543e10emr10689852wru.60.1647091753470; Sat, 12 Mar 2022 05:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx08jwnIztDnOLiXVDOEbPcafrm/CtfYrKe3rhTTULaSTSBSgqOJ8fo2V1YMqeSSpK6UdbZbQ== X-Received: by 2002:a5d:4dca:0:b0:1f0:2543:e10e with SMTP id f10-20020a5d4dca000000b001f02543e10emr10689827wru.60.1647091753256; Sat, 12 Mar 2022 05:29:13 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-174-239.adslplus.ch. [188.155.174.239]) by smtp.gmail.com with ESMTPSA id p22-20020a1c5456000000b00389e7e62800sm5751550wmi.8.2022.03.12.05.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Mar 2022 05:29:12 -0800 (PST) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: 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 , Rasmus Villemoes , Krzysztof Kozlowski Subject: [PATCH v4 00/11] Fix broken usage of driver_override (and kfree of static memory) Date: Sat, 12 Mar 2022 14:28:45 +0100 Message-Id: <20220312132856.65163-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-20220312_052921_019092_708C1AAE X-CRM114-Status: GOOD ( 15.73 ) 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 v3 ======================= 1. Wrap comments, extend comment in driver_set_override() about newline. 2. Minor commit msg fixes. 3. Add tags. 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, merging and stable ================================ 1. All patches, including last three fixes, depend on the first patch introducing the helper. 2. Merging idea: everything via driver core (Greg KH?). 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 | 56 +++++++++++++++++++++++++++++++++ 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 | 6 +++- 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 | 6 +++- include/linux/device/driver.h | 2 ++ include/linux/fsl/mc.h | 6 ++-- include/linux/hyperv.h | 6 +++- include/linux/pci.h | 6 +++- include/linux/platform_device.h | 6 +++- include/linux/rpmsg.h | 6 ++-- include/linux/spi/spi.h | 2 ++ include/linux/vdpa.h | 4 ++- 24 files changed, 171 insertions(+), 205 deletions(-)