[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220120175140.D8989C340E3@smtp.kernel.org>
Date: Thu, 20 Jan 2022 09:51:39 -0800
From: Stephen Boyd <sboyd@...nel.org>
To: Daniel Latypov <dlatypov@...gle.com>
Cc: Michael Turquette <mturquette@...libre.com>,
linux-kernel@...r.kernel.org, linux-clk@...r.kernel.org,
Brendan Higgins <brendanhiggins@...gle.com>,
kunit-dev@...glegroups.com
Subject: Re: [PATCH v2] clk: gate: Add some kunit test suites
Quoting Daniel Latypov (2022-01-19 22:26:50)
> On Wed, Jan 19, 2022 at 9:23 PM Stephen Boyd <sboyd@...nel.org> wrote:
> > +
> > +static void clk_gate_test_exit(struct kunit *test)
> > +{
> > + struct clk_gate_test_context *ctx = test->priv;
> > +
> > + clk_hw_unregister_gate(ctx->hw);
> > + clk_hw_unregister_fixed_rate(ctx->parent);
> > + kfree(ctx);
>
> I think we forgot to drop some kfree's now that we're using
> test->priv = ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL);
>
> This will result in duplicate kfree's.
Good catch! I forgot that it was a managed allocation like that. Doesn't
help that I had to go all the way to the kunit_kmalloc_array()
kernel-doc to read that test managed means it is freed when the test is
done.
> > +
> > +static void clk_gate_test_is_enabled(struct kunit *test)
> > +{
> > + struct clk_hw *hw;
> > + struct clk_gate_test_context *ctx;
> > +
> > + ctx = clk_gate_test_alloc_ctx(test);
> > + ctx->fake_reg = BIT(7);
> > + hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7,
> > + 0, NULL);
> > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw);
> > + KUNIT_ASSERT_TRUE(test, clk_hw_is_enabled(hw));
> > +
> > + clk_hw_unregister_gate(hw);
> > + kfree(ctx);
>
> ditto
>
>
Thanks! Next time can you trim your mails? It's quite long and I have to
scroll down to find everything.
Powered by blists - more mailing lists