Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp116578pxm; Tue, 1 Mar 2022 16:22:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJziQau2NWtmhN+oohQFdTM5P+4/oaqcaS5VQCoSkJRK6ldQthejQllHBxaVmkbYoJQNgR6U X-Received: by 2002:aa7:94b7:0:b0:4f4:117e:13cc with SMTP id a23-20020aa794b7000000b004f4117e13ccmr13130652pfl.66.1646180568349; Tue, 01 Mar 2022 16:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646180568; cv=none; d=google.com; s=arc-20160816; b=E4To4HKP3/BnSUb8yu/KXB5ji1Jghm19VQvauVGge90Q1wYOjtnAcxO101ZW242XYG JRTT6PoDkA3FQ8ZWRePsSy8mbJ1GX6OM9L73e37mFq0EPy91Zm1MFet8F8VBRWDuXHQ/ UP654nsQ/zD9cfHsAjbbWwLjYPu5syMtxShE9Cs97Qn8TFlNSgQbpRJhfxRdQbap4J8O gFXgY/67ZpFZCyBJ8K28rxhwFToFUvV9w1VVo5y5k2chsafxiI9Jxu+86s1x5TPdSDrT e4UQMDI3CqSsjSTcMp2Zk2vSOb85XKfYYD+ODRHIDg53RnbUJFCLIRhD8s9C2il5cSqg ZMvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Y86hBfPWj9E4aTo+XMBrAu6Y5p4SQMawkPD4Q/SuKPY=; b=FK4cx7mxGZ213jl4ExSTvS8XDXERIbPAJDWpiJqHZFVvgw3TSy6cNW3DLqI5Rovtkd y2jmQDOMG0XP2SCgQA7VMNr3R62os3kJavbTJNDRuZEXOC24apHyhNQ8npyx3rK9ZlRa 9u4L7CkGCPSEVS8NyH0WdZ+sMdmUf19lRFYQFvFn6mCOMY1n+Z3HOrjlz+kDphMySyGW cpEps1RxOh4DDtoDr9XpTkoEWZH2xtCSpfrrhvyyQM8D3uUCfrhQ6bNuevpEP88Y7Km+ mDrxRnst5a+0QVwVB4jE7CcjU39/c1JhQvkH2p0sX9vE0yTLXTTNIqVgcTWe4IN+rzJ+ waRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ifR445Pt; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a056a0015d500b004e1523f2f32si6426241pfu.337.2022.03.01.16.22.25; Tue, 01 Mar 2022 16:22:48 -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=@linaro.org header.s=google header.b=ifR445Pt; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236083AbiCAR3L (ORCPT + 99 others); Tue, 1 Mar 2022 12:29:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbiCAR3J (ORCPT ); Tue, 1 Mar 2022 12:29:09 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B9E220F60 for ; Tue, 1 Mar 2022 09:28:27 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id v2-20020a7bcb42000000b0037b9d960079so1701047wmj.0 for ; Tue, 01 Mar 2022 09:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Y86hBfPWj9E4aTo+XMBrAu6Y5p4SQMawkPD4Q/SuKPY=; b=ifR445Ptk0kZIwyK/iR5LauUeexT4h+Xm5fWIS9UfHsJTwIXI+TBUH0b1B1nklV58Q e3posB9tDmWAuXNqOByYa8OEIeuEgFpyIkDoWKkxe1RAiCnFE6ZEzQVCpMvS62fGzNFV nWcw5JV2lmoD9jxvmDMFuNVsgy/NwYWUQ6a0I1zB2e5jSr3/JFEIp9xW/NRIDhtT+/y6 uvAB7/5ZICC2qcmaHb2EAlpVYU+L8My5syB7aELi6iajmzjea09g2vNncJq3GY6hv/nP g2d17hu4ZYUIRYCXpyuRUhAY/Kr9r3k7MyrtDEVfLOZZZFWPJ239r6w7DpTzLNolCHHw A62A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Y86hBfPWj9E4aTo+XMBrAu6Y5p4SQMawkPD4Q/SuKPY=; b=mWvEGWNOL8/6yfyWCWvEvBDVOwBHPCxJ0EZaSZQuIKt08uE1affpPkgwMYgmEOiQHA VieNsXtjG51HQS37DOPi+n9iz1teTh5VxaFwcptpsxXnsDJYBTl72pFv/t2joL6BIR1v X1u4nyW0uFPnUSbb71oNNuAfUJMv2bgPV6ddmfslXkxp0uU2H51OIfIXgrYQWbdnLYyu suzyBIQhjmrF1g8ZkasNKE+BOI2SqLTcH9ZnTB+V1UUCNdkOJHl7SVYJto21bV1LonUO oExv4mmyRJOA46KlgVUF4ey6EC4fwAdBwcqFf0R1TxpwOSnKlM6J3/juDbb5XIIf4Z5X VN8A== X-Gm-Message-State: AOAM533j1XZMdVko2UCdIWlc6e+AnSnXeOb2xP+XDdYsyoHf+J9PShOS yrZ6O8unRQP+wGUVFSsZ2scW+g== X-Received: by 2002:a05:600c:a4b:b0:37b:ea2b:5583 with SMTP id c11-20020a05600c0a4b00b0037bea2b5583mr18173339wmq.139.1646155705687; Tue, 01 Mar 2022 09:28:25 -0800 (PST) Received: from [192.168.86.34] (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.googlemail.com with ESMTPSA id c4-20020adfed84000000b001e5b8d5b8dasm20457807wro.36.2022.03.01.09.28.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 09:28:24 -0800 (PST) Message-ID: <5f481315-021c-39d6-8c6c-91918851ab13@linaro.org> Date: Tue, 1 Mar 2022 17:28:22 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 10/11] slimbus: qcom-ngd: Fix kfree() of static memory on setting driver_override Content-Language: en-US To: Krzysztof Kozlowski , 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 , 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 , stable@vger.kernel.org References: <20220227135214.145599-1-krzysztof.kozlowski@canonical.com> <20220227135329.145862-4-krzysztof.kozlowski@canonical.com> From: Srinivas Kandagatla In-Reply-To: <20220227135329.145862-4-krzysztof.kozlowski@canonical.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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 On 27/02/2022 13:53, Krzysztof Kozlowski wrote: > 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 LGTM, Reviewed-by: Srinivas Kandagatla > --- > 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; >