[PATCH v3 10/23] clk: Add clock driver for the RISC-V RPMI clock service group

Andy Shevchenko andriy.shevchenko at linux.intel.com
Fri May 23 09:35:05 PDT 2025


On Thu, May 22, 2025 at 06:44:09PM +0530, Rahul Pathak wrote:
> On Mon, May 12, 2025 at 12:38 PM Andy Shevchenko
> <andriy.shevchenko at linux.intel.com> wrote:
> > On Sun, May 11, 2025 at 07:09:26PM +0530, Anup Patel wrote:

First of all, remove all unneeded context with which you are agree.
I should not crawl through dozens of lines of the email to see what
you wanted to discuss. Take it as everyday practice, please.

...

> > > +     /* Validate RPMI specification version */
> > > +     rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SPEC_VERSION);
> > > +     ret = rpmi_mbox_send_message(context->chan, &msg);
> > > +     if (ret) {
> > > +             dev_err_probe(dev, ret, "Failed to get spec version\n");
> > > +             goto fail_free_channel;
> >
> > This is simply wrong. You should not do goto before any devm_*() calls.
> > The error path and ->remove(), if present) is broken. Fix it accordingly.
> >
> > Here should be
> >
> >                 return dev_err_probe(...);
> >
> > it's your homework to understand how to achieve that. Plenty of the examples in
> > the kernel.
> 
> So far I could only find drivers with "goto used before devm_*" pattern used.

Of course, because they are wrong and most of them need fixing.
(Yes, there are some exceptional cases, but I don't believe it's many)

> Can you please point me to the example which does not use goto before
> devm_* apis.

Tons of them, any which starts with devm_*() call in the probe, most of the
drivers/iio/, for instance. Just a random pick here: drivers/iio/accel/bma400*.

(and FWIW it was indeed the very first driver I was looking into while writing
 this email)

> Also, I couldn't understand the problem which may happen because of
> this. Can you please explain?

devm_*() defers the resource deallocation to the end of ->remove() and error
path in ->probe(). This breaks the symmetry of the allocating / deallocating
resources. At worst case it will be an Oops on ->remove() or when error happens
during the ->probe().

...

My gosh, the original text was quoted twice! Next time I won't even look into
the email reply which won't have a reduced context.

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-riscv mailing list