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 E2F49C4332F for ; Tue, 31 Oct 2023 09:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbjJaJiA (ORCPT ); Tue, 31 Oct 2023 05:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbjJaJh7 (ORCPT ); Tue, 31 Oct 2023 05:37:59 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3729EBB for ; Tue, 31 Oct 2023 02:37:57 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCFF4C433C7; Tue, 31 Oct 2023 09:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698745076; bh=/kqgdwPcRLog5aV2/n8Ciql+xEQo+PR4MoBPHvAJkoU=; h=Date:From:To:Subject:References:In-Reply-To:From; b=pcaFfrhnX59u3UPg/fwZ9ykyus5+gXcenIhFKX5iVmQNwqwq/WZxo7IO7RCdU461a EHg4mhkPqidAc/Dj9oT71X6Yx3MNm9q1mY0ak80K//xa0E6HnybDF46sMQ3HnoCr5Z 0BvuZMUvOLt56JuCnK45nS+zmz0DZ/mFR7F4ikbMcpUXme6QvssD1qmk8/hKDYR6oa LKQSoKLf5LbkEwGqY2Cn0dYfCUV96xRfu3hnxQkhoR+DOFs9uAxhL4V/WpQ+oeVsSw HyJoKJjlxGLlpZNHfTYnba5YCeK2hdpCnbfe357Y66J4VJwpPJCQtb16BIKHMjYiwz ZWj5U7+Bq1PTQ== Date: Tue, 31 Oct 2023 09:37:53 +0000 From: Lee Jones To: stable@vger.kernel.org, Krzysztof Kozlowski , "Rafael J . Wysocki" , Greg Kroah-Hartman Subject: Re: [PATCH 1/6] driver: platform: Add helper for safer setting of driver_override Message-ID: <20231031093753.GW8909@google.com> References: <20231031091521.2223075-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: <20231031091521.2223075-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: I131f04170f2f76d468565b27929e0ee6fd0e7adf Disregard this set please! I'm pre-coffee and operated in the wrong kernel directory with the incorrect `commit-msg` enabled. -- Lee Jones [李琼斯]