From patchwork Tue Feb 22 13:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12755084 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 DB3ABC433F5 for ; Tue, 22 Feb 2022 13:30:19 +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:References:In-Reply-To: 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: List-Owner; bh=t/3OXfTq30Ew8jXRKJ2ShCLj7riac8/vTlrDVruvND8=; b=KfOAxozWmAu1bs AgewVI6uYzogG0kzrS8WvK0nlY7u4RsnqkR1CdFiWQ+NV1icnzsavQPNaGkh3wEFZRGB+BXWkGYgV 2K35100aTld6/49aW/zqSDmrh4yDGO1MaLSf0mDj3ig8i+MPSkPPJwc5vjlTkKxeRWBa5UVkDjEyj nlWBgQ9v+3ok2lFqyBsABSe77Xg9WSoOg7RBhNRvwcAG+cMshaqH7PJboVd+FOzjU8FLQd9AYDf7o /hmSnKQz/7kRebiVfKayrYUjZuu6WbV9C+9sZ0PrfTMqiGvVx/iMUDma8OhY0t9n0SaWiSCuZjOSc 4umxuycsBo1GgjxvuvzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMVDp-009h8v-VD; Tue, 22 Feb 2022 13:28:54 +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 1nMVDk-009h61-H5 for linux-arm-kernel@lists.infradead.org; Tue, 22 Feb 2022 13:28:50 +0000 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.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 1D68D40257 for ; Tue, 22 Feb 2022 13:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645536522; bh=bxf6nJLttPRsL7dBKXZgcCS/RsJRiJgMR1Ys1z/0BT0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=inPGJiFGhpmqpC1lplrkZmDrG4enItXj5xARB4lc5cdaeYCynhjHV2uOwA8PmECTy +p18O+fob5cZLtKcwYR5rkT35eF76SFdv5eeC3b+0QpiJFGGJdva3uMcBpI5pzJXut XR3oQR1k3OsUZzL10usZUAPNg4IdlM9iVm3K5096lfFrrjknmUjOtHlBfD+61UtmC7 qR5tY01GVdFkcVaF/GJtQmL3SkJH9gEjIRuyNSbWhdUuk0ZDNnuLfU1+2ni/BpR71i f5/y3xmggk2fVxa9ZfH0oDnj0i9qPemKf9NkxtOmUV9HAV4pXPe8k/oIMl6caNXTPO Kbn9U5mt2m0xg== Received: by mail-ej1-f71.google.com with SMTP id mp5-20020a1709071b0500b0069f2ba47b20so5694754ejc.19 for ; Tue, 22 Feb 2022 05:28:42 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bxf6nJLttPRsL7dBKXZgcCS/RsJRiJgMR1Ys1z/0BT0=; b=sbzJEoTvIvjpKRcYS6WHRzV25EI57uIg9Ve8djcqCyv4M6Z8z3xJY95z6OrkRXuOiO RgVBPMnknG6R1LKxnCHcLSP/rRCqAXaAxe7RMr3jvtHQ4EWzyJy7Z9AgMSBuC2nzpSxt aVkTc1ErV3vS7jDiL9Z/P0Pj9E40pWX/jcr8mm2OIKugzs6Rb3djG1eYSdviqU6jXnUz pDRcWn4gy8nib3d5X6CIuHghTYzH05dblDLpGHFgrUOsxEuT6OudPvf3VAHfRtvvQMde PXKSpk9II4FJ1cvy0cXoT624eBC2ZxW97oYBMmlC1Z0CWXb+qivJ6kbSi0+Jp6uZv8F0 apRg== X-Gm-Message-State: AOAM532yxE9yxl0Dri/8cYci91PWNXtNnYuDlunY3CMCPSO/PdwohpkS DExjUPOUPzyYosG465qQghNb8ZjjEjHJcC2+5qlrYu5reCCq0iYlvlqQE466T5tFHuhpZZ4B0op 1JEnuR2dOt0zo3ee6RVZ55nrzhzgP6La7X61pKci1J1TS6os3Squt X-Received: by 2002:a17:906:a08b:b0:6cf:65bc:e7de with SMTP id q11-20020a170906a08b00b006cf65bce7demr19077964ejy.220.1645536521799; Tue, 22 Feb 2022 05:28:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUTH4XEfwD3KKh1b8myIZr/sth4y54qNnWupnWL+QunNk7jf61nPg0M2zH6cCPLQ41ESwuWQ== X-Received: by 2002:a17:906:a08b:b0:6cf:65bc:e7de with SMTP id q11-20020a170906a08b00b006cf65bce7demr19077951ejy.220.1645536521622; Tue, 22 Feb 2022 05:28:41 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id c5sm10029875edk.43.2022.02.22.05.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 05:28:41 -0800 (PST) From: Krzysztof Kozlowski To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bjorn Andersson , Mathieu Poirier , Andy Gross , Srinivas Kandagatla , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [RFT PATCH 1/3] clk: imx: scu: fix kfree() of const memory on setting driver_override Date: Tue, 22 Feb 2022 14:27:05 +0100 Message-Id: <20220222132707.266883-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> References: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_052848_708413_2C75E48C X-CRM114-Status: GOOD ( 14.80 ) 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 driver_override field from platform driver should not be initialized from const memory because the core later kfree() it, for example when driver_override is set via sysfs. Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/clk/imx/clk-scu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index 083da31dc3ea..78ed40a0e3e2 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -683,7 +683,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name, return ERR_PTR(ret); } - pdev->driver_override = "imx-scu-clk"; + pdev->driver_override = kstrdup("imx-scu-clk", GFP_KERNEL); + if (!pdev->driver_override) { + platform_device_put(pdev); + return ERR_PTR(-ENOMEM); + } ret = imx_clk_scu_attach_pd(&pdev->dev, rsrc_id); if (ret) From patchwork Tue Feb 22 13:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12755085 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 39A05C433F5 for ; Tue, 22 Feb 2022 13:30:26 +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:References:In-Reply-To: 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: List-Owner; bh=HpFSaFvGG4Pmu4gblt6h37W6j83CfRXNjVJaJAFtND4=; b=dAUYhqi0wYrKmA wff4AMlsxK04hb4gvo5/IEHNBA4pTK3yaZQKQ4kfHxSlLeY2AIIWlmSX8UWR4G6CGkU/zKNmf3zap hTnbisTA8ww2JOM3t2Oavat4RGjbI+e8Xn4DSqSjI9rVYmenAnONus90L9JXqTSicVW9ESgOtI1H6 XyXXbfbFCv1udvgP8jaIRgOt2tVOM6+U1FxIQutSXPEb7290HpR+BoERbXjwloPdfSkRgbnI89qgZ oOK8VI8K8EP/gy8xi75EZjgtNuFlg/8i3yVf2yop/4fMvfAYYW5sTBCvcbSCDCKUuz92UVMQR2FEA Il7tVCEV3pzJXH/GS7tQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMVDz-009hC6-Qk; Tue, 22 Feb 2022 13:29:04 +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 1nMVDk-009h5z-Jx for linux-arm-kernel@lists.infradead.org; Tue, 22 Feb 2022 13:28:51 +0000 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.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-1.canonical.com (Postfix) with ESMTPS id CD38440304 for ; Tue, 22 Feb 2022 13:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645536523; bh=6XeuQoqUzMUksn+ZuaBzNCPcuTk2LLoHTJkT0DsbDHY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VKZlwWJ7g99WEIyofZ1MqRBQ33PrEKi+p/W7fixuZQiEB/2X+gc7Gr1iVWam0e3WU WitLCT92mAbGqReCm8y7JpBUs6MydgHKfP42Wa0RKywCLmybZslSxnPsQnxIWqbdMS Wh2bH6R/iRuOS/f46edLeQ1SwRPr4WjRlIKwSj9k+Njfw/eMmhKurQEr8LVtP2bptT DTj7i+gBtR9MDPAmIgpM00OfYXO9DwszqnfySNSSG2kdlGbws+f0lfuukin297dUab baGeaV8BHHyE5Kz8XyC7Nvrtq2ne0jQnhlJAYDJ12SNAj7wLVDL2deWf7FjC029JJe dFlN85JCHLnvw== Received: by mail-ej1-f71.google.com with SMTP id ga31-20020a1709070c1f00b006cec400422fso5743278ejc.22 for ; Tue, 22 Feb 2022 05:28: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:in-reply-to :references:mime-version:content-transfer-encoding; bh=6XeuQoqUzMUksn+ZuaBzNCPcuTk2LLoHTJkT0DsbDHY=; b=rNofBsdrR+zi525d+pfo79Hb61MCJ6U15PbCd/HCayBcnyft3u90bS5GvMfJ+yONfH RcaAm5eVKEC6Aek+EejDGUNDZwqUr9vrGDUEsLbdpQ0JBgFO6RSNebQj5umahvKQNLwi q+gFHYhUdmTccGqSYQfAfufizQZm2rVWA1QoYJ4XVEYO1fOpfjs7VbilS9yjFAlNi0YX jHy7svnT1DqN3sTIehKUAkWAEQKXoQf136nbdkN6DIuiuIOGbRuVtCDzBiRYeOAlmgRv OdQ/bbhqucH+6y5B5X76mlceGBE1mIHn74Wgee4PEGvLmNCZaCw6/LZjPTH3xZBubNTp /Gvw== X-Gm-Message-State: AOAM5316NYYPPmag4gJdxaDoXltIYvTJQBPfgczBs0MWpiAd+wYsYQZm MWm9jG+2SyKgu6Y2ILm5hIFRdd4sMMg+1mbUVROKHifqtyo4MjezSgvWML71oooY62wsVhVl1v8 6A6BJ8M7gj5U6QYg4jffO25p7RyIMJti01j74o+BJTofRVfnRW27/ X-Received: by 2002:a17:906:1656:b0:6cf:571c:f91d with SMTP id n22-20020a170906165600b006cf571cf91dmr19602342ejd.377.1645536523432; Tue, 22 Feb 2022 05:28:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJymWh8nTis0+whBJdlEUIaYxkLfPNPRZyT/AbiwgON8MIxb/gad15tlt22GRXjxl9FycTeAJw== X-Received: by 2002:a17:906:1656:b0:6cf:571c:f91d with SMTP id n22-20020a170906165600b006cf571cf91dmr19602313ejd.377.1645536523213; Tue, 22 Feb 2022 05:28:43 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id c5sm10029875edk.43.2022.02.22.05.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 05:28:42 -0800 (PST) From: Krzysztof Kozlowski To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bjorn Andersson , Mathieu Poirier , Andy Gross , Srinivas Kandagatla , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [RFT PATCH 2/3] slimbus: qcom-ngd: fix kfree() of const memory on setting driver_override Date: Tue, 22 Feb 2022 14:27:06 +0100 Message-Id: <20220222132707.266883-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> References: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_052848_823099_4424AD87 X-CRM114-Status: GOOD ( 14.87 ) 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 driver_override field from platform driver should not be initialized from const memory because the core later kfree() it, for example when driver_override is set via sysfs. Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/slimbus/qcom-ngd-ctrl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 7040293c2ee8..5987d8f8a8fd 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1455,7 +1455,14 @@ static int of_qcom_slim_ngd_register(struct device *parent, } ngd->id = id; ngd->pdev->dev.parent = parent; - ngd->pdev->driver_override = QCOM_SLIM_NGD_DRV_NAME; + ngd->pdev->driver_override = kstrdup(QCOM_SLIM_NGD_DRV_NAME, + GFP_KERNEL); + if (!ngd->pdev->driver_override) { + platform_device_put(ngd->pdev); + kfree(ngd); + of_node_put(node); + return -ENOMEM; + } ngd->pdev->dev.of_node = node; ctrl->ngd = ngd; From patchwork Tue Feb 22 13:27:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12755087 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 3AC78C433F5 for ; Tue, 22 Feb 2022 13:30:45 +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:References:In-Reply-To: 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: List-Owner; bh=5QdOFhBjwAwrsVoHrWQhSgx/UGFpiEuqKC3hrnax9Sg=; b=hpYd9dtIeuixvV 1cQrXUYl7NuiBUS9MedcE0hoSeMpeXcVetX7BuMisBX2eOGZYIS5g2E70BqihjZViI/ECDnym6kMr Z+uhqqhi4T6lOSTFejBacDVmpV1QxucQ2LIZfQzwNPnhPVDcQvrBl3CWaxLTyNHEM5Py+PQiEq6yb H2msj0o+J1OTiI/aUIJD3p7fAb1ffW7WzdAVIffijq043q9Iwz7EXIbAkeohZV0sOahtLGo3+flmn iaiOA7kELa0ro1jRPJ2FvfXznVraZVqzHM/Hl9Bem8Mz4ZrPRHb1+OXFpF6zfhib3e34yhyOKmVit 6LEeosO5u5KgjEy1sOJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMVEJ-009hG3-Vc; Tue, 22 Feb 2022 13:29:24 +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 1nMVDk-009h6B-Lr for linux-arm-kernel@lists.infradead.org; Tue, 22 Feb 2022 13:28:52 +0000 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (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 9580F40253 for ; Tue, 22 Feb 2022 13:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645536525; bh=4gAKTfhEbiOa5VKlvnZrWEbzuOeUPflEFSiM68fpB+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dkYI8QB+a7ihANAbPp67FEFYSsTNU7f+rC+C/bV0S9rQ4WP5qUoFjkZa4gza16jvU cP0TSqxFDRjILd5ggExIYtRMR3Ql0+8HEwbIZ1ywFXs60RFnOJS02ZM4sR0QIKFWCs eaxREbZn9gis9Y/dy/BS2YQm1WOfa1Rvt0mtlUp2xc9gumju1UCnYQjVEXdLhaUrps d8RljRvvp068RxFSPE9gnoRvc00sjabOYqf+qhRBnYi2XoXnArV/RptJSxvv5UwyUF 98BKEIIjI7tXBjKm1z25FqwmTkXCkWP+v7YQUB1TAS+4ikgvkrc3se3clYy4iPeTbU 3RscVdDMUeM2g== Received: by mail-ed1-f72.google.com with SMTP id d11-20020a50c88b000000b00410ba7a14acso11951385edh.6 for ; Tue, 22 Feb 2022 05:28:45 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=4gAKTfhEbiOa5VKlvnZrWEbzuOeUPflEFSiM68fpB+I=; b=Z6tdCMR+iIaX1QmJ/PPydLRzzHJrRKHkz/PwxRVvyMyxjE2q5RteCDDwJvOf0mJtKJ X1E0AJl7++AFcjkm2huDEn57c9KBl6Lkeptz3v0u7NOAZLzkv4SzltfrBn2wIYdfr58B HQw0JzarO51zXtT9them7B/5V7nwWPkPu2UOEI1yCheMMNadI3REWArJTFroVlKpuxUH aCr1NxXuEbDCZMqZcbvkMJDUm9Tn9GxJpsX4cMoNQ17a7R2G2fILGjcpYjh6f+gxxcaW knw0WZb1efmSXqQ8t0k5rUjk3qiFioaeBOf+gPjPqxquiv0gxngZlMhh2QnIBmkHEJl8 AKBA== X-Gm-Message-State: AOAM5324nPPOMzEgFc25ZDGNtgtyRPRJwFCNWk+VAi1yRKEs7JyT7zSc CN6LxXZJLt/hoH184KVOax1vVqGsf5c0cMPgKU1w9X/onnuyTPQr07fGEJUIWpW1JB6lefDDl1n JYc3eTbyE3ZqnihVB2IKWnPDcj9NAbdTTADi5wFZ4mZYgZWNGsEP1 X-Received: by 2002:a05:6402:50d2:b0:413:1cd8:e08e with SMTP id h18-20020a05640250d200b004131cd8e08emr4730743edb.276.1645536524861; Tue, 22 Feb 2022 05:28:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyk7fFQMdh++yZYYeqYdt0QvvL2iwrOb2soDeyOFOcCMFVM9JS2wL10Ee7DBznFmZmRSj/ibA== X-Received: by 2002:a05:6402:50d2:b0:413:1cd8:e08e with SMTP id h18-20020a05640250d200b004131cd8e08emr4730720edb.276.1645536524647; Tue, 22 Feb 2022 05:28:44 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id c5sm10029875edk.43.2022.02.22.05.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 05:28:44 -0800 (PST) From: Krzysztof Kozlowski To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bjorn Andersson , Mathieu Poirier , Andy Gross , Srinivas Kandagatla , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [RFT PATCH 3/3] rpmsg: fix kfree() of const memory on setting driver_override Date: Tue, 22 Feb 2022 14:27:07 +0100 Message-Id: <20220222132707.266883-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> References: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_052848_873833_81190D1D X-CRM114-Status: GOOD ( 14.81 ) 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 driver_override field from rpmsg_device should not be initialized from const memory because the core later kfree() it, for example when driver_override is set via sysfs. Fixes: 950a7388f02b ("rpmsg: Turn name service into a stand alone driver") Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/rpmsg/rpmsg_internal.h | 12 ++++++++++-- drivers/rpmsg/rpmsg_ns.c | 13 +++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index b1245d3ed7c6..c21e73ffbf05 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -92,10 +92,18 @@ int rpmsg_release_channel(struct rpmsg_device *rpdev, */ static inline int rpmsg_chrdev_register_device(struct rpmsg_device *rpdev) { + int ret; + strcpy(rpdev->id.name, "rpmsg_chrdev"); - rpdev->driver_override = "rpmsg_chrdev"; + rpdev->driver_override = kstrdup("rpmsg_chrdev", GFP_KERNEL); + if (!rpdev->driver_override) + return -ENOMEM; + + ret = rpmsg_register_device(rpdev); + if (ret) + kfree(rpdev->driver_override); - return rpmsg_register_device(rpdev); + return ret; } #endif diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c index 762ff1ae279f..7d0605307d23 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -20,12 +20,21 @@ */ int rpmsg_ns_register_device(struct rpmsg_device *rpdev) { + int ret; + strcpy(rpdev->id.name, "rpmsg_ns"); - rpdev->driver_override = "rpmsg_ns"; + rpdev->driver_override = kstrdup("rpmsg_ns", GFP_KERNEL); + if (!rpdev->driver_override) + return -ENOMEM; + rpdev->src = RPMSG_NS_ADDR; rpdev->dst = RPMSG_NS_ADDR; - return rpmsg_register_device(rpdev); + ret = rpmsg_register_device(rpdev); + if (ret) + kfree(rpdev->driver_override); + + return ret; } EXPORT_SYMBOL(rpmsg_ns_register_device);