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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A90DC433B4 for ; Wed, 7 Apr 2021 11:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3C646113B for ; Wed, 7 Apr 2021 11:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347001AbhDGLhv (ORCPT ); Wed, 7 Apr 2021 07:37:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351859AbhDGLht (ORCPT ); Wed, 7 Apr 2021 07:37:49 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1825DC06175F for ; Wed, 7 Apr 2021 04:37:39 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id y5so18210441qkl.9 for ; Wed, 07 Apr 2021 04:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IW3oRRx99M57CpJG31OJ6s9cRTtaL0D26Vt6HdVUzpk=; b=oopYu+YQ42DBdZzN3yOYVkLE34+WNijKBfVjcKw6QPwW/mRKOs2n2G4L1YfBrga8cx 220R9uTBCCRVSD1cy6bDEd7gA1lnF9TD+T4FpdSH5e6pDE7WFLCti3vaDYFyC2SgaM9z dzLQKaRLpCgPt311J8OYBUcFJAbeRxPMkE31g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IW3oRRx99M57CpJG31OJ6s9cRTtaL0D26Vt6HdVUzpk=; b=SPRH+j9JXTEJDH1QPNVYpJSnBiRhZZNekQ6i5bU01IejZFnxJ2SPZ+x0sXefmLT2Zp ZKsU2HBnaTiAR5L3CJ6E+lXqXTR13AGpzd6HdFY3kHxrrdgncCFmMUgHh9YQOAi8oD++ RSLT/9Xvv5piyqbGo4CsLIYFvjzpoxtEv+OTaJHOxE13c9gC4Y2rT27OuU/38RIPdLYY Y/aMy52kMO13jEpBHjcdrgHjwWMF4D0brQZ85ynXurOt0PKQMBYW520P0alvTxl+M54J Zpc4M6MptjQ2ps9Dtjz9tGKfSd0hQWhL3NyNVMAdr4S4Qc5injFtAtIZe3nooOPvEuNI LezQ== X-Gm-Message-State: AOAM5301h51GnQ+zDUx1/EQHh+ugSN+4B9nYYuHfE9YrViFdPSsbp4K4 qL+dWvefI5a6dXfDD/w/fPblGE7A9V2cVrsZn3dOm3qtBsU= X-Google-Smtp-Source: ABdhPJyA5Hg5hcZK/lrBzsOg/7n5zpjnXNILiWuDcgO2g8kFHFN6fUKV9nWalWac9N9CBudJ/zH0+3dvbyRGFrd6m4Q= X-Received: by 2002:ae9:f70a:: with SMTP id s10mr2714172qkg.468.1617795457907; Wed, 07 Apr 2021 04:37:37 -0700 (PDT) MIME-Version: 1.0 References: <20210406230606.3007138-1-dmitry.baryshkov@linaro.org> In-Reply-To: <20210406230606.3007138-1-dmitry.baryshkov@linaro.org> From: Daniel Palmer Date: Wed, 7 Apr 2021 20:38:56 +0900 Message-ID: Subject: Re: [PATCH] clk: fixed: fix double free in resource managed fixed-factor clock To: Dmitry Baryshkov Cc: Andy Gross , Bjorn Andersson , Stephen Boyd , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Rob Clark Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Hi Dmitry, On Wed, 7 Apr 2021 at 08:06, Dmitry Baryshkov wrote: > > devm_clk_hw_register_fixed_factor_release(), the release function for > the devm_clk_hw_register_fixed_factor(), calls > clk_hw_unregister_fixed_factor(), which will kfree() the clock. However > after that the devres functions will also kfree the allocated data, > resulting in double free/memory corruption. Just call > clk_hw_unregister() instead, leaving kfree() to devres code. Doh. Sorry for not spotting this when I wrote the patch. Thank you for cleaning up after me. Cheers, Daniel 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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 312F9C433B4 for ; Wed, 7 Apr 2021 12:38:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0A006117A for ; Wed, 7 Apr 2021 12:38:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0A006117A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=0x0f.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 187D36E0E3; Wed, 7 Apr 2021 12:38:31 +0000 (UTC) Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB02F6E0B6 for ; Wed, 7 Apr 2021 11:37:38 +0000 (UTC) Received: by mail-qk1-x72c.google.com with SMTP id o5so18338486qkb.0 for ; Wed, 07 Apr 2021 04:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IW3oRRx99M57CpJG31OJ6s9cRTtaL0D26Vt6HdVUzpk=; b=oopYu+YQ42DBdZzN3yOYVkLE34+WNijKBfVjcKw6QPwW/mRKOs2n2G4L1YfBrga8cx 220R9uTBCCRVSD1cy6bDEd7gA1lnF9TD+T4FpdSH5e6pDE7WFLCti3vaDYFyC2SgaM9z dzLQKaRLpCgPt311J8OYBUcFJAbeRxPMkE31g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IW3oRRx99M57CpJG31OJ6s9cRTtaL0D26Vt6HdVUzpk=; b=pdmgZMAxrS/8f3a3y2bS9eQWCL+UpcpS4sPFSnbyJHnF5ZQIr9kKyUaLpcvEyLRku8 mtLYx+Ok2Fr6DlC30uce19ZNbxdBnKaXBPODlgK/2ljQWrtG8Sn3ZPQy4AjKRz3v8SXV SofG7hiFScK/xde5zjmOjTVxhwrXm/mjSh/sFb9pvR/aT9E2KjRvMQAr2NgHeuINIZj5 FAbhAB2RkLDJMRa5yq7PuIlm1rn2BrtQdKvSefe9nvAm76moF/q2Q0Sl/3mvO/7zJyAa vt6zOF2H0zEIDo0ZAZjo13TFdFbD+fUhsryDMPGNnTAM7N4foKbKBaTHtHLKdVWUTxOu nSSQ== X-Gm-Message-State: AOAM533g/zrz6p/N6kyCb/rTel81j1UshGX4qk4pXuTujbi+0XV73I3y TjA2iDL1oaF9A6zNk699LHPF9oKjhGbPmgZhO1SbZw== X-Google-Smtp-Source: ABdhPJyA5Hg5hcZK/lrBzsOg/7n5zpjnXNILiWuDcgO2g8kFHFN6fUKV9nWalWac9N9CBudJ/zH0+3dvbyRGFrd6m4Q= X-Received: by 2002:ae9:f70a:: with SMTP id s10mr2714172qkg.468.1617795457907; Wed, 07 Apr 2021 04:37:37 -0700 (PDT) MIME-Version: 1.0 References: <20210406230606.3007138-1-dmitry.baryshkov@linaro.org> In-Reply-To: <20210406230606.3007138-1-dmitry.baryshkov@linaro.org> From: Daniel Palmer Date: Wed, 7 Apr 2021 20:38:56 +0900 Message-ID: Subject: Re: [PATCH] clk: fixed: fix double free in resource managed fixed-factor clock To: Dmitry Baryshkov X-Mailman-Approved-At: Wed, 07 Apr 2021 12:38:30 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Stephen Boyd , linux-arm-msm@vger.kernel.org, Michael Turquette , dri-devel@lists.freedesktop.org, Bjorn Andersson , Andy Gross , freedreno@lists.freedesktop.org, linux-clk Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Dmitry, On Wed, 7 Apr 2021 at 08:06, Dmitry Baryshkov wrote: > > devm_clk_hw_register_fixed_factor_release(), the release function for > the devm_clk_hw_register_fixed_factor(), calls > clk_hw_unregister_fixed_factor(), which will kfree() the clock. However > after that the devres functions will also kfree the allocated data, > resulting in double free/memory corruption. Just call > clk_hw_unregister() instead, leaving kfree() to devres code. Doh. Sorry for not spotting this when I wrote the patch. Thank you for cleaning up after me. Cheers, Daniel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel