Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1287442pxb; Thu, 14 Apr 2022 02:46:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMtIVTRNYfI66X4UBgKelbDCSx4ePpkyLIfQkw4rr4YPGz6g32vikwiFMOA9UIZFn0Ohym X-Received: by 2002:a63:1215:0:b0:39c:fa33:9427 with SMTP id h21-20020a631215000000b0039cfa339427mr1611821pgl.296.1649929614640; Thu, 14 Apr 2022 02:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649929614; cv=none; d=google.com; s=arc-20160816; b=qk1V82Rmlf2Ram1c/4JS4SKuCA1RJPjW6/S0NjGAFmoHaxA8qyfhBdyI6LifGlz2Eo fiFpv3Y59FwZc/Jng9kQVelUfY0nXL1e/HPhT7oOXLJ+EYDnyXGC0nUbw72GqPn2+pBE J1QvTSrArali2Ljk618D98wGQMFDkZgvoYWfdvzVq7z+UahPHLgYGVyNBs6wbxSWr2al HbOFxH5P8gc2GM2zLXOck9aWKFcicWGgD1ZHeNcMEhtd8zz2cwck5Grhuao4pS45nhbL Q+aTbW/aiNfi6XRb1EoVFjjA7c0F0s9XRckGFeh3dkc0xwATiyux/alReTzaociXF1s1 R7AA== 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=vnyM2Iiv5ssFwZ+YfhSIPkTVc84CfyYTFaqlrMujJwU=; b=X/dA1zq9jC5u0FoOvKGO05VGJD0wfSPucC+7taz4f0zUgRENdhtvWKLfNtCD47SEsC b+fwqqa+pJAEXjoOyJwYWElbFvYaSbc/vJ3CIET1toNNctC5AsuQXT+7wKg0I1MQ2q+i HpYrtxk/aA4nB7QV46VKzqENcJnoqHYSTV3rbqlAbz+8J6qWTg12nYzGC3ddKgBaN/jJ z1WpI9K7yYS3hRgUwHgE71I0tLcnPxrgFfiiWziAUuQGkPuomUzwiwtZjd1pRboNf8nl tSp0Ya7T4zuFVrA4MKEucWnPlm0qnCWL5QxiIGSp/HQhPJtIJTLnvlkxQtiLEwXAMRnW AKTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JIbqyng6; 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 z16-20020a1709028f9000b00156fdfa2003si15431328plo.473.2022.04.14.02.46.42; Thu, 14 Apr 2022 02:46:54 -0700 (PDT) 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=JIbqyng6; 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 S232978AbiDMInd (ORCPT + 99 others); Wed, 13 Apr 2022 04:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234486AbiDMInX (ORCPT ); Wed, 13 Apr 2022 04:43:23 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 642C24707D for ; Wed, 13 Apr 2022 01:41:00 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id v15so1449029edb.12 for ; Wed, 13 Apr 2022 01:41:00 -0700 (PDT) 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=vnyM2Iiv5ssFwZ+YfhSIPkTVc84CfyYTFaqlrMujJwU=; b=JIbqyng6xlRV93M1Iu4dTb27ybe+M5EN2beeOTia2QovfKwHZWLGjr66cUx0YdX3/v 8nbu5XWVqbuUMx1VHW7Jp0LjTMIRW/JvtKlPAPwmC12IguAK8nAZjvST8nPijS6soEVz lCEGXpJKRGImWyHRDfmKyn0IwmzTivzO/Vs8MDv+1cJ+MoZ5YxwAJ+kc5wqtfsrfRjlw dl24/2CzxrUZbd2CgYUV995GGUYyvDMWOghjruTd1pRrJ7LcOsA6BV8p7XbkZUzO9Tat 9Hf6SigjF0nx23JEKIGKUT0nPYsQzEA7bWg8dt6IDJV7Ni9PpqpqRJKKkXLn7s8NY1Kj Fn2A== 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=vnyM2Iiv5ssFwZ+YfhSIPkTVc84CfyYTFaqlrMujJwU=; b=udAXJ42Wwa31lufBN7Y+quyG5xViGxQWVWwhLQBLg+qp9Z7KAvZMsJqYDCnMLcSGHB DeirX7f++Ph836SdUaPkhs330xPptq3xDHElvySIYmaUPPO5bCTY3sxPJs2mLiVNMmK1 KwawkdAPLB5MJZWxU2f82APyKX2mGcoJt7/bDZV0oUnIVkoKYvYnBxetn0CkhX91iFWN sUsnk584NA7kbkTaO9Y8xC84NgzFuu6kbDJEb5TwZ3jXYkrQQ5osTaC/JoqHw52O5t9b GNCcB/DpWT2CtUkfYHcJbdm5ve6jmq2F1ke9GjsPvf0OU+GCjbugmkoJ/fqHEhcUJ3s6 R7fA== X-Gm-Message-State: AOAM533iK7nKtsVJ0K8h6zNoBFAMy7wKMKnf0PdP2a4jZKhYAlQC282h U/13ihYMPYuSLNOtyHhEYVuUlQ== X-Received: by 2002:aa7:c40b:0:b0:41d:9886:90a0 with SMTP id j11-20020aa7c40b000000b0041d988690a0mr5089328edq.275.1649839258932; Wed, 13 Apr 2022 01:40:58 -0700 (PDT) Received: from [192.168.0.202] (xdsl-188-155-201-27.adslplus.ch. [188.155.201.27]) by smtp.gmail.com with ESMTPSA id o15-20020a50d80f000000b0041cc1f4f5e0sm902910edj.62.2022.04.13.01.40.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Apr 2022 01:40:58 -0700 (PDT) Message-ID: Date: Wed, 13 Apr 2022 10:40:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v6 12/12] rpmsg: Fix kfree() of static memory on setting driver_override Content-Language: en-US To: Biju Das , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Stuart Yoder , "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 , "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 , Rasmus Villemoes , Andy Shevchenko References: <20220403183758.192236-1-krzysztof.kozlowski@linaro.org> <20220403183758.192236-13-krzysztof.kozlowski@linaro.org> From: Krzysztof Kozlowski In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 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 12/04/2022 16:10, Biju Das wrote: > Hi Krzysztof Kozlowski, > > Thanks for the patch. > >> Subject: [PATCH v6 12/12] rpmsg: Fix kfree() of static memory on setting >> driver_override >> >> 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: 950a7388f02b ("rpmsg: Turn name service into a stand alone driver") >> Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface") >> Signed-off-by: Krzysztof Kozlowski >> Reviewed-by: Bjorn Andersson >> --- >> drivers/rpmsg/rpmsg_internal.h | 13 +++++++++++-- >> drivers/rpmsg/rpmsg_ns.c | 14 ++++++++++++-- >> include/linux/rpmsg.h | 6 ++++-- >> 3 files changed, 27 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/rpmsg/rpmsg_internal.h >> b/drivers/rpmsg/rpmsg_internal.h index d4b23fd019a8..1a2fb8edf5d3 100644 >> --- a/drivers/rpmsg/rpmsg_internal.h >> +++ b/drivers/rpmsg/rpmsg_internal.h >> @@ -94,10 +94,19 @@ int rpmsg_release_channel(struct rpmsg_device *rpdev, >> */ >> static inline int rpmsg_ctrldev_register_device(struct rpmsg_device >> *rpdev) { >> + int ret; >> + >> strcpy(rpdev->id.name, "rpmsg_ctrl"); >> - rpdev->driver_override = "rpmsg_ctrl"; >> + ret = driver_set_override(&rpdev->dev, &rpdev->driver_override, >> + "rpmsg_ctrl", strlen("rpmsg_ctrl")); > > Is it not possible to use rpdev->id.name instead of "rpmsg_ctrl" ? > rpdev->id.name has "rpmsg_ctrl" from strcpy(rpdev->id.name, "rpmsg_ctrl"); > > Same for "rpmsg_ns" as well It's possible. I kept the pattern of duplicating the string literal because original code had it, but I don't mind to change it. In the output assembler that might be additional instruction - need to dereference the rpdev pointer - but that does not matter much. Best regards, Krzysztof