Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2058198pxm; Sun, 27 Feb 2022 10:04:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOW+4/L5SKGHQiHR6pnH843h9no+ga7ue2Uetsp3MSlIn2LPcEc25mHeD/e/r3420zziNA X-Received: by 2002:a50:aac8:0:b0:410:ae77:c484 with SMTP id r8-20020a50aac8000000b00410ae77c484mr15841662edc.431.1645985056989; Sun, 27 Feb 2022 10:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645985056; cv=none; d=google.com; s=arc-20160816; b=ekQYiDdRsviz9QpU4QaWrtlhgon4OD3HJRMu6rPezzO8WDr4J251rvUNlguRhj9bu1 zSqBnhOYxOZH8bez5wReKqxPEuZ7SfGMqkECFgdGQv4oEg5S8ANu4H3dqiLh7mDuEB1a j410svMH4x0wlJjIGEYZE4foOyXwQ3TaFJ+Mpa+E/u0VKZ7J/Ku/ItavWCPpK256VS62 UEIjuk0N0pSSUIGxuQdo35B67dlBtHgo6I5MlT+hPxv8wJ/S0JPcjXefgpXMx6l/N31O kr6i3kAE2HXNj3tLF7xO9nqwG2q2obOog/KHrdCSBcHjvKPG84y1glQ9WgAhFabAwSLA vFEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=beBPqukoSZCIAAv6gBbQLkWehzWMNdiQtzWlJ1M8u3o=; b=vp7KFWGw6/RQmCEM1CJwyWvBM1mlzjQA5qZ6iIdmrkcpLss2mzbqKoDTmw72UL0/8y oZ2SDjbYZWb/dIsnP9XRBvsuXrRBhwleXYW6JWOCVx05+VHkMZCpdEi8LaZz6Rk+U1Ef jHvCjarqkKWXyLzGq/CW7Xgc1/BiI9ZNs+igTASEIe0qYmOXt90P4UQ3Tf6scMRaBMJB 24QFbcsA2CSweIx0NLspLb3LpFusnjNTKh6HkwzRm6yC6EmQ0dQAHWnYLLvjQyabJw+J twhnz3BYej1SbjE3BOtSYWiRWXUjtve4Gn4U5LFfStYVyvtWp83ODphP+rlf3Pgpwkhw omNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=n+5o2Quq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw15-20020a170906bccf00b006ce0e757e64si4782923ejb.807.2022.02.27.10.03.52; Sun, 27 Feb 2022 10:04:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=n+5o2Quq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbiB0Nx0 (ORCPT + 99 others); Sun, 27 Feb 2022 08:53:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiB0NxX (ORCPT ); Sun, 27 Feb 2022 08:53:23 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 412A965BD for ; Sun, 27 Feb 2022 05:52:43 -0800 (PST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.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 6512840300 for ; Sun, 27 Feb 2022 13:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645969952; bh=beBPqukoSZCIAAv6gBbQLkWehzWMNdiQtzWlJ1M8u3o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=n+5o2Quq7M9byT70m/qbScueEGjHYHdl7Azplo/F/s9AZMlOjpfZVKpTfKFQGoRi/ iCyOzkZVd0LSIZT9F4NuadPH+ZR2rRpImOsLak2F2jtzy5lSBGLXl8m5U40r3eXsB2 zCZo9VieIVQpG3QuF1M83XjMVapLo6fErknNw0O99p4Uwezbjp1KWkQsvY1g0z91kG Hdo1OslIuSdByBjyo/xtfdajm904IMTqcjdpPE5jTV92bjkWg3/BbwejnMTNyVkL0b QmHPVVmYHqw2MbHbVoXU6FfzY5ru3Suew5wrcf6td6idjliLLU3ElgPL4IIz1YO8tK bBK8WJzzuJqKA== Received: by mail-ed1-f71.google.com with SMTP id e10-20020a056402190a00b00410f20467abso4240162edz.14 for ; Sun, 27 Feb 2022 05:52:32 -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=qJYoT8N3ABkhAtuDA8p4S5AsNJ56rboiQD5qj1sqcR99Fp7SxAybluhIhdaCpvnEc/ BN+fsEqGsIaMAB5xYg99v42u0vUrnaH0IQgyCi2U9HvvrFZKIkP95QnTUN6AV10TIVXv mhOSTG0h54qoOlnpD11TCuLkfG6YYZqVTV4QbqhrpsdG3xYav93QLdmFME32IfzS0wnk L4tzQU28yckRe/dOsZlyNvgA8/BlZlq9PUX8yBVppDCeURd8l+6PDsombhfJ/PFZUoDI Cyo99cm244sVbniyaJ8MQSktIxzSix48N9AnYO7jeDgIVQV4Su9DVCK1jLSuQKsDIanU 1vZw== X-Gm-Message-State: AOAM533ldakR5FTKJw2adi7GxxPAwVX0jySHYzXy56n9L9vU7Lqt9qvg VOXdbyFMnaO4BiSGjFthZjxDqu7XfXJiQqx+zR9yadzfccPXdBt8kFXwhILveyTqqh+8KSY1t/M CMZTapH8v/9S9SQP2ZYHGKQvNKN2Yf3JNgknZENR9/w== X-Received: by 2002:a05:6402:50d4:b0:413:2a27:6b56 with SMTP id h20-20020a05640250d400b004132a276b56mr15602847edb.228.1645969951010; Sun, 27 Feb 2022 05:52:31 -0800 (PST) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) -- 2.32.0