All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Daniel Latypov <dlatypov@google.com>
Cc: Michael Turquette <mturquette@baylibre.com>,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	Brendan Higgins <brendanhiggins@google.com>,
	kunit-dev@googlegroups.com
Subject: Re: [PATCH v2] clk: gate: Add some kunit test suites
Date: Thu, 20 Jan 2022 09:51:39 -0800	[thread overview]
Message-ID: <20220120175140.D8989C340E3@smtp.kernel.org> (raw)
In-Reply-To: <CAGS_qxoMRsvx8HDex9Aq9KUALAQrdNe3VVYikyzT59TEYfbLdg@mail.gmail.com>

Quoting Daniel Latypov (2022-01-19 22:26:50)
>  On Wed, Jan 19, 2022 at 9:23 PM Stephen Boyd <sboyd@kernel.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.

  reply	other threads:[~2022-01-20 17:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20  5:23 [PATCH v2] clk: gate: Add some kunit test suites Stephen Boyd
2022-01-20  6:26 ` Daniel Latypov
2022-01-20 17:51   ` Stephen Boyd [this message]
2022-01-20 17:58     ` Daniel Latypov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220120175140.D8989C340E3@smtp.kernel.org \
    --to=sboyd@kernel.org \
    --cc=brendanhiggins@google.com \
    --cc=dlatypov@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.