From patchwork Mon Feb 18 10:15:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 10817661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D5D51390 for ; Mon, 18 Feb 2019 10:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67E7B2A376 for ; Mon, 18 Feb 2019 10:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AFB42A380; Mon, 18 Feb 2019 10:16:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0DA712A376 for ; Mon, 18 Feb 2019 10:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eS9St/FgXnRvX+OMKkPZQCCLN5Jba8WSxIlrrY53VWo=; b=UGKwCr2hsGAIs2 pr/rCIWEKozXDuS4InFs71ZlcAdVIL6rHal4H55jZG06ozAEvnkPLGQILhn47N+72lscQT4ZRa/mF /5W8/UykbnU3Jm6JT5f31UBsy1ftc1tYneo4058NMcdPi1ZIeg4E+wOwn4o1H0rM6zcAgUoyePcbK BCrfw+8eq4xzBGuHO42CwKepSF7G14VAKUD3l0E0VT8f5A4oqX9aJkkPMuMa8wnJ2XWj953yyQtas pKwOvryTXwdCU0NDHypHdZlv8QLD0ACFl1S5tgiyt02jF9LzXhEzPKXqNLu2AMUqUI2w4ce1Ep0iX t1J7H32ZDeA8twNgm9Ug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvfym-0008Ij-LY; Mon, 18 Feb 2019 10:16:52 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvfyj-0008IM-DB for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 10:16:50 +0000 Received: from PC-kkoz.proceq.com (unknown [213.160.61.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B854B21736; Mon, 18 Feb 2019 10:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550485009; bh=ddJqJt7L1B19SoK0shSpKHfK4DacqUl0AdkTNtfUPec=; h=From:To:Subject:Date:From; b=fhEyw7A+rYG2d125tPjdiE1N0SW2Qrl8r7RweaM6UQmZ8IAr9oTmyIASpJx/Tl7dz K0sQcn4ieyfLy2WdcM2j/0sl2vtujVIgB2tMkZ4w4kKgUFZrpWinGMF2ke0Hbn1fOX oBO+PSeFxX44hdHyi/lyiG6OSSiqWsOIE95e/EWQ= From: Krzysztof Kozlowski To: Russell King , Mark Brown , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Sylwester Nawrocki , Tomasz Figa , Chanwoo Choi , Michael Turquette , Stephen Boyd , Kukjin Kim , Krzysztof Kozlowski , Andy Gross , David Brown , Srinivas Kandagatla , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Subject: [RFC 0/4] clk/driver: platform: Fix kfree() of const memory on setting driver_override Date: Mon, 18 Feb 2019 11:15:56 +0100 Message-Id: <1550484960-2392-1-git-send-email-krzk@kernel.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190218_021649_467319_6CA1152D X-CRM114-Status: GOOD ( 10.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, The problem =========== Several device types (platform, amba, spi etc.) provide a driver_override field. On sysfs store or during device removal, they kfree() the existing value. However the users are unaware of this and set the driver_override like: pdev->driver_override = "exynos5-subcmu"; which obviously leads to error. Solution ======== I provided simple helper for platform device. If this approach is acceptable, I can convert also other buses, like AMBA, SPI. Dependencies and pick up order ============================== Patch 1: please pick it as is through clock tree Patch 3: Depends on patch 1 (merge conflict) and 2. Patch 4: Depends on patch 2. Best regards, Krzysztof Krzysztof Kozlowski (4): clk: samsung: exynos5: Fix possible NULL pointer exception on platform_device_alloc() failure driver: platform: Provide helper for safer setting of driver_override clk: samsung: exynos5: Fix kfree() of const memory on setting driver_override slimbus: ngd: Fix kfree() of const memory on setting driver_override drivers/base/platform.c | 63 ++++++++++++++++++++++---------- drivers/clk/samsung/clk-exynos5-subcmu.c | 12 ++++-- drivers/slimbus/qcom-ngd-ctrl.c | 2 +- include/linux/platform_device.h | 9 ++++- 4 files changed, 61 insertions(+), 25 deletions(-)