From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Salah Triki <salah.triki@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: trigger: use put_device() in viio_trigger_alloc() error path
Date: Mon, 16 Feb 2026 09:55:11 +0200 [thread overview]
Message-ID: <aZLNX6Ifw68k-zu5@smile.fi.intel.com> (raw)
In-Reply-To: <20260215222348.186806-1-salah.triki@gmail.com>
On Sun, Feb 15, 2026 at 11:23:47PM +0100, Salah Triki wrote:
> Once `device_initialize()` is called, the lifecycle of the trigger must be
> managed by the kobject reference counting. Currently, if `kvasprintf()`
> fails, the code manually calls kfree() and `irq_free_descs()`.
>
> Switching to `put_device()` ensures that the device's release callback
> (`iio_trig_release()`) is properly invoked. This simplifies the error
> path by centralizing the cleanup logic (including `irq_free_descs()`)
> inside the release handler, following the standard driver model pattern.
How did you test this, please?
...
> struct iio_trigger *viio_trigger_alloc(struct device *parent,
> trig->name = kvasprintf(GFP_KERNEL, fmt, vargs);
> if (trig->name == NULL)
> - goto free_descs;
> + goto free_trig;
>
> INIT_LIST_HEAD(&trig->list);
> return trig;
>
> -free_descs:
> - irq_free_descs(trig->subirq_base, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
> free_trig:
> - kfree(trig);
> + put_device(&trig->dev);
Now, in iio_trig_release() you will call a bunch of code with
trig->subirq_base != 0.
Please, test your changes before submitting.
> return NULL;
> }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-02-16 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-15 22:23 [PATCH v3] iio: trigger: use put_device() in viio_trigger_alloc() error path Salah Triki
2026-02-16 7:55 ` Andy Shevchenko [this message]
2026-02-16 8:45 ` Salah Triki
2026-02-17 13:51 ` Nuno Sá
2026-02-17 15:08 ` Andy Shevchenko
2026-02-18 9:14 ` Nuno Sá
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=aZLNX6Ifw68k-zu5@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=salah.triki@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox