X-Received: by 2002:a17:90a:9ec:b0:1bc:50bc:e058 with SMTP id 99-20020a17090a09ec00b001bc50bce058mr12240355pjo.183.1645667529936; Wed, 23 Feb 2022 17:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645667529; cv=none; d=google.com; s=arc-20160816; b=jteRmPDXveQvudso1C+HATigh/Z6+0turc3nug5tYtrUv6Ity7X32UeuMxFRIRfgBh EczEXewz+/zKQ5dQdFU+E7qWMileBfOK7qcvLQ4UWhiFvjsexgL+uL9Sk0/whdaUzUSl 3ddr7duvHRZBdae+GPcM7ORX6cueU/w4IiAaLIKHyY1u7ZrMJew87OxDErxDVzYNvF5r +jFhLhCSPkZ/24HZ1xn8VM1eIgdwly8Yi76ai9asLF/1UY+WoWHhIuAc/8lIRw+eHF2v ffLsx1yAX4qnitbUsNxF5BRIO421pt5jfOl5B9ax8QeVMihtm8CO/oV15PmOIqN8s5Vc u99Q== 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=oRXS+YkCrSg6HXmKQBekF6bqmCpfytEa7gv0higjFpc=; b=LwYGdWicqPiIFRS0SW2H2rdR3N5qdjhG0nhq2xQQ9DSNdsWWyqSMDZ5vhRJ+KxGgy2 7TbgDkhT7C0M1mw44DqNKpao3f0F+SUI4YsJuRMYTS3c97vx54/C11Dh3kMcwYVMImxf GLXAiYdQXy4Vtzw8ldLHaq2YxVmba5xuSKr1PKEwi+UxTS4r058MHwglw6rIK2tGvJ0G OFq1GB4hoLTn8R2Fke4tF8jmYemR2j9xvulpLDaljTwHjUQlsGc0GJ2A9L4qDbWD7LPM ZuewhQ5fqEKAUzDkev41CyfdYpa/eDzig06l0ogiSsRNfiBiP+Dz9gXd3WrWUEq7yL0Q zN/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=n9ojWeXj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i16si1187735plg.54.2022.02.23.17.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:52:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=n9ojWeXj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D45F22A283; Wed, 23 Feb 2022 17:23:53 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244268AbiBWTQU (ORCPT + 99 others); Wed, 23 Feb 2022 14:16:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244300AbiBWTQN (ORCPT ); Wed, 23 Feb 2022 14:16:13 -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 16D86424B6 for ; Wed, 23 Feb 2022 11:15:42 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (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 D4D9540A60 for ; Wed, 23 Feb 2022 19:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645643740; bh=oRXS+YkCrSg6HXmKQBekF6bqmCpfytEa7gv0higjFpc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n9ojWeXj5f5HdqLQaLUtbcudXGE633b373RIFFO7xOnyB376ClS6dt5F6r/KBiko+ P/x96dEX1o/ab+W5HjSBoEmLuwsDERkQLCD7A0zKmeVzk5JyQUnlKvuVKc6samLd6A VX97MdCMw8xK90Gl9uokGcyO5Wwg3vqFyy+aW03LesT8EDKQ/O92ab9vCOiHheJpTM EIzrLifa+89qHURcZngqGdi5SMCl7pZJy8bnXgd7951kjkUbix/XFB3eG3ogKq3m09 NDTnOCyD7AGmRsSt9Mit10rZKaHtEQSuRusFyfBAozL9C/itMm7iQGdsAneMpnNgeu Y9L1wlxyynMWw== Received: by mail-wm1-f69.google.com with SMTP id h206-20020a1c21d7000000b003552c13626cso1540517wmh.3 for ; Wed, 23 Feb 2022 11:15:40 -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=oRXS+YkCrSg6HXmKQBekF6bqmCpfytEa7gv0higjFpc=; b=2Lr1SXGlXPBlRRMwe5ZeUY1rHc2/l49XASu841gn2NlcXP96RvQpM000R9gffDhsN3 RYTIktZSTh5Nr2Kg0DqR9L+B7bTSHHjkyMK5VOyKRKsaa9Z5OysU8wB/eDWvnI1W2NP5 wTgP76QrTzdG6noi1W8g2Hx3JIoOwvbeeXncdEMxRC8nu22me8vH1e1HlxFePt5n8j8D wo+Ho+nBjGw+RM+kw6lt+kr7d5ONnRLku942ur+X8J9qr3jUuZOhdcB1tLOasdGfLWlh N5yNLM8jddsRHnW+Q9u7TGpe8QU1ZAJGvNBFddS8J2xkCnG6tNqA3U824gZiShqsf8NN XN6w== X-Gm-Message-State: AOAM530VoLkN6GGOai0pV9rpeX27sYm9EV4ayFU3iTV3g6kMeLUZfUeR Yx5xfky6URoZ1J1KTl1XkaTVQCT2EMhIjkdz/bPsM98uklk7a8Vfv2Y0wOu2cIErDa5Zyvi4h2S TQgrheCCbJHv28dTWma0XUz5cPO/289nT3M871wKbgA== X-Received: by 2002:a05:6402:3487:b0:40f:fa53:956c with SMTP id v7-20020a056402348700b0040ffa53956cmr894427edc.22.1645643729011; Wed, 23 Feb 2022 11:15:29 -0800 (PST) X-Received: by 2002:a05:6402:3487:b0:40f:fa53:956c with SMTP id v7-20020a056402348700b0040ffa53956cmr894395edc.22.1645643728802; Wed, 23 Feb 2022 11:15:28 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id b3sm208368ejl.67.2022.02.23.11.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 11:15:28 -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 v2 10/11] slimbus: qcom-ngd: fix kfree() of static memory on setting driver_override Date: Wed, 23 Feb 2022 20:14:40 +0100 Message-Id: <20220223191441.348109-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> References: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 7040293c2ee8..e1a8de4d41fb 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,16 @@ 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); + 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