Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1961309pxm; Sun, 27 Feb 2022 07:34:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi+FBylfFh09OOAa+RWkx/K+udW0KGv29f/MOaiIrlYIvZm9yt9H1CX+cBfZ+S7m0QQcq7 X-Received: by 2002:a17:906:a08b:b0:6b9:2e20:f139 with SMTP id q11-20020a170906a08b00b006b92e20f139mr12828485ejy.463.1645976068392; Sun, 27 Feb 2022 07:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645976068; cv=none; d=google.com; s=arc-20160816; b=HQ07RYvNdewpGMXP6oS8r+FM0wL2IXLIAGTZ82t20vU3cCC0A0y5ArFRMBGN4VFnKb S9COjD/rE4ewdQqhYf7zACeGpCKJRS68fUM6yXtjKBtBstqTJXg/zg9upnjdYw2LtuY7 n0FhxI7jUtwns/ELGEuMypPcrBv7Y1v1Ifl7BMumjOaDKuQUXVQc4NdyX95hS6wNQ7PZ TWxK4nwapvI/gaaLy7YzN0M63PJ+a7GiR3znQiTgwTiYMFQ6b5HzAGlIxsBHMGJh0NNf RRZNOYB3hiyAFQp0ctOmvbgw0sVUN5sJXUBy9Pc9u2hvy71nKz77koO2wvJgJNygFPUT rLDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ittcal6Pd+WYY4FgdYnMj0oR0y7noG6anoPNpq8mwII=; b=ft+o2nKP2L/EhV0g+F/xA82CaPu3YzSnrVZ/vxK18gruMtvWtgTatVIgZfivkkeI5G Ywj9CpbD07b7GEwVeWrk/80Gsq5z73CZneuYHG6WWLCuqU/Jki0+wKMrwXNMLULUwviZ 1CxB3K5budt8f/YL994oDuqrrIqmM+hUdusY/KfO9X1qlcU0UXwXmPLRiwou8kok/vYh 5Mhc7kCDn0bNCNftT0vFrUivXQZDiWSd8QxgwAA5trImSKHN2UVA8Fuciu/s0JGd3NfY q8MHg0Y/hZ8WzBSXimqDUILXjxh9LmglOGupqed6Gh9VRGlSMPAn04DmSEdUopCQiMTq E7Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=MfA22CvY; 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 r12-20020aa7d58c000000b0041361cb470asi5073078edq.316.2022.02.27.07.34.06; Sun, 27 Feb 2022 07:34:28 -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=MfA22CvY; 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 S231287AbiB0NyZ (ORCPT + 99 others); Sun, 27 Feb 2022 08:54:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbiB0NyV (ORCPT ); Sun, 27 Feb 2022 08:54:21 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89E2113EBE for ; Sun, 27 Feb 2022 05:53:42 -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-1.canonical.com (Postfix) with ESMTPS id 727933FCB0 for ; Sun, 27 Feb 2022 13:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645970021; bh=Ittcal6Pd+WYY4FgdYnMj0oR0y7noG6anoPNpq8mwII=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MfA22CvYBUUIvpI2+eRjFniMalFMd4ttSDNNE2THW8LMvYQE2vU9yoZoCLyjpvUGY eMi+gnCiYrdx+ASWsEmSeaQ0sRRGQhdPC0fY7Q3vnqit/HBXD5dTH2s7usPeZs9tOi XH6DrS/oXKXpmQOgrG42dlxpFlLNAjqmu43zZqrRsK2BqJiGvU0OzTHH+kOEhYgF6k SI1zwH1csmWBNL3yGEGIGhiU+SQu6agY+E02WoQ5VWDctAxAkMPLrzVUrqRzXNpm9V AtmVCISUOXGHmJajn9Nfd+Sawa5MsYNXA6oHYM/yM69yPhlJkNtLvgs+gN20ze7uX9 jAucYoCN0v3aQ== Received: by mail-ed1-f71.google.com with SMTP id l3-20020a50cbc3000000b0041083c11173so4254511edi.4 for ; Sun, 27 Feb 2022 05:53:41 -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=Ittcal6Pd+WYY4FgdYnMj0oR0y7noG6anoPNpq8mwII=; b=bJBrmVn8qT7FKJe5NgmWWNmU8xlYdHA6eJnofZHG6B8i+KX6k+qtzTtpbdtvdaUYnN VXtgWLRqPkx769xJqpS8oXkIuCnvFbBOeNwksI7Xg8AuaHCsFsgcDU8VbUsP1X8g6i/6 25pYxjEoZnSffslp/f4+6X1ioRBt8GihQkw+fIJCXTLrmeL1G5Pbi7uK1N4XB9Nt2XtR 4ZTfn0ReQLwx8xh78g9D8qflBYdmtSA+Y5x1IP1rZbhXKalYcxsXrQocGQ5pm5Sra/U7 BE+ONwQJhRtZKu7Ty3fTbMslaP2JxWhna/CTJfh5JQ4b3uCywZmPYrVChrDeFmtY5noM Kopg== X-Gm-Message-State: AOAM533lCgE2mdx/MWXcdSxeJR39lYPDHiaDwNi5sZs5DkIhEOc+kYcn qVkVHDjl8wDCt5PS6C1q7JMyh2Zw7ZCW4hEJRCB9ar5lQSFBEJUJS28S8DpfNSDAmGAvyP0y2+R trWOo8t3wHg6/QI5t1jfGdxabuvn0KUD0q54fnbHuHw== X-Received: by 2002:a05:6402:42c6:b0:412:8cbc:8f3d with SMTP id i6-20020a05640242c600b004128cbc8f3dmr15364981edc.310.1645970020961; Sun, 27 Feb 2022 05:53:40 -0800 (PST) X-Received: by 2002:a05:6402:42c6:b0:412:8cbc:8f3d with SMTP id i6-20020a05640242c600b004128cbc8f3dmr15364941edc.310.1645970020805; Sun, 27 Feb 2022 05:53:40 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id w11-20020a056402128b00b00412ec3f5f74sm4600760edv.62.2022.02.27.05.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 05:53:40 -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 , stable@vger.kernel.org Subject: [PATCH v3 10/11] slimbus: qcom-ngd: Fix kfree() of static memory on setting driver_override Date: Sun, 27 Feb 2022 14:53:28 +0100 Message-Id: <20220227135329.145862-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220227135214.145599-1-krzysztof.kozlowski@canonical.com> References: <20220227135214.145599-1-krzysztof.kozlowski@canonical.com> 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=unavailable 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 The driver_override field from platform driver should not be initialized from static memory (string literal) because the core later kfree() it, for example when driver_override is set via sysfs. Use dedicated helper to set driver_override properly. Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/slimbus/qcom-ngd-ctrl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 7040293c2ee8..e5d9fdb81eb0 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1434,6 +1434,7 @@ static int of_qcom_slim_ngd_register(struct device *parent, const struct of_device_id *match; struct device_node *node; u32 id; + int ret; match = of_match_node(qcom_slim_ngd_dt_match, parent->of_node); data = match->data; @@ -1455,7 +1456,17 @@ 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; + + ret = driver_set_override(&ngd->pdev->dev, + &ngd->pdev->driver_override, + QCOM_SLIM_NGD_DRV_NAME, + strlen(QCOM_SLIM_NGD_DRV_NAME)); + if (ret) { + platform_device_put(ngd->pdev); + kfree(ngd); + of_node_put(node); + return ret; + } ngd->pdev->dev.of_node = node; ctrl->ngd = ngd; -- 2.32.0