From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DEADC4332F for ; Tue, 31 Oct 2023 09:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjJaJhg (ORCPT ); Tue, 31 Oct 2023 05:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbjJaJhf (ORCPT ); Tue, 31 Oct 2023 05:37:35 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDEEBF4 for ; Tue, 31 Oct 2023 02:37:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DB89C433C8; Tue, 31 Oct 2023 09:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698745052; bh=hV9XQ4OgHHek9uObDnGpMwTGF4BvT050vong/FbchE4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=gKzhlgfWPzQ9LEEUSjir751kapauzp2SUmGpvQcBQEdx04VluN/aDr+h6KJF49Jeo qr+nSTgpNGEM6sSchI9u3+ud6E29PfRr140Pz5n5aUDbATIo+qKaDaNfOhuFalp0Pi AYEH/0ZSfjt4DiSh4ZfOYi2E5jeKmfnFuZybbDAj9WNuDSCLZgFSji1pkj7T+BaHqB 5OsPEfdfbtUKXAQ0moFllnZ8P933Yh8Mt1hSUJf3pyTRzh39nSzVT1SpldgSy9C07y k0GrFpzHaSggzAtN5xtfz/ijvv/RaPAdK/W145xtuhw5JBOhiQVkJ9iyB9tmnk05N6 x+ImRZjCEjtcA== Date: Tue, 31 Oct 2023 09:37:28 +0000 From: Lee Jones To: stable@vger.kernel.org, Krzysztof Kozlowski , "Rafael J . Wysocki" , Greg Kroah-Hartman Subject: Re: [PATCH v5.10.y 1/6] driver: platform: Add helper for safer setting of driver_override Message-ID: <20231031093728.GV8909@google.com> References: <20231031092308.2227611-1-lee@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231031092308.2227611-1-lee@kernel.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Tue, 31 Oct 2023, Lee Jones wrote: > From: Krzysztof Kozlowski > > commit 6c2f421174273de8f83cde4286d1c076d43a2d35 upstream. > > Several core drivers and buses expect that driver_override is a > dynamically allocated memory thus later they can kfree() it. > > However such assumption is not documented, there were in the past and > there are already users setting it to a string literal. This leads to > kfree() of static memory during device release (e.g. in error paths or > during unbind): > > kernel BUG at ../mm/slub.c:3960! > Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM > ... > (kfree) from [] (platform_device_release+0x88/0xb4) > (platform_device_release) from [] (device_release+0x2c/0x90) > (device_release) from [] (kobject_put+0xec/0x20c) > (kobject_put) from [] (exynos5_clk_probe+0x154/0x18c) > (exynos5_clk_probe) from [] (platform_drv_probe+0x6c/0xa4) > (platform_drv_probe) from [] (really_probe+0x280/0x414) > (really_probe) from [] (driver_probe_device+0x78/0x1c4) > (driver_probe_device) from [] (bus_for_each_drv+0x74/0xb8) > (bus_for_each_drv) from [] (__device_attach+0xd4/0x16c) > (__device_attach) from [] (bus_probe_device+0x88/0x90) > (bus_probe_device) from [] (device_add+0x3dc/0x62c) > (device_add) from [] (of_platform_device_create_pdata+0x94/0xbc) > (of_platform_device_create_pdata) from [] (of_platform_bus_create+0x1a8/0x4fc) > (of_platform_bus_create) from [] (of_platform_bus_create+0x20c/0x4fc) > (of_platform_bus_create) from [] (of_platform_populate+0x84/0x118) > (of_platform_populate) from [] (of_platform_default_populate_init+0xa0/0xb8) > (of_platform_default_populate_init) from [] (do_one_initcall+0x8c/0x404) > > Provide a helper which clearly documents the usage of driver_override. > This will allow later to reuse the helper and reduce the amount of > duplicated code. > > Convert the platform driver to use a new helper and make the > driver_override field const char (it is not modified by the core). > > Reviewed-by: Rafael J. Wysocki > Acked-by: Rafael J. Wysocki > Signed-off-by: Krzysztof Kozlowski > Link: https://lore.kernel.org/r/20220419113435.246203-2-krzysztof.kozlowski@linaro.org > Signed-off-by: Greg Kroah-Hartman > Signed-off-by: Lee Jones > Change-Id: Ic3c1fefbb9bf1a27f7adcca5bf0405e02d2f7775 Disregard this set please! I'm pre-coffee and operated in the wrong kernel directory with the incorrect `commit-msg` enabled. -- Lee Jones [李琼斯]