From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH v2 1/7] serdev: add proper error cleanup to serdev_device_open()
Date: Thu, 12 Feb 2026 23:02:03 +0100 [thread overview]
Message-ID: <20260212-vmaster-customers-leicageo-system1600-v2-1-f590b7d5b0e9@pengutronix.de> (raw)
In-Reply-To: <20260212-vmaster-customers-leicageo-system1600-v2-0-f590b7d5b0e9@pengutronix.de>
The serdev_device_open() function is missing a proper error cleanup
which is fixed by this commit. Unfortunately we don't have scoped
accessors yet, therefore the 'old' goto must be used.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
common/serdev.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/common/serdev.c b/common/serdev.c
index 5399a2062722dc12fe5241bdf4a466606af053bb..8f45c0a135237da42579bbb685c9c25a67428c8b 100644
--- a/common/serdev.c
+++ b/common/serdev.c
@@ -71,21 +71,39 @@ int serdev_device_open(struct serdev_device *serdev)
serdev->buf = xzalloc(PAGE_SIZE);
serdev->fifo = kfifo_alloc(PAGE_SIZE);
- if (!serdev->fifo)
- return -ENOMEM;
+ if (!serdev->fifo) {
+ ret = -ENOMEM;
+ goto err_free_buf;
+ }
ret = poller_async_register(&serdev->poller, "serdev");
if (ret)
- return ret;
+ goto err_free_fifo;
ret = console_open(cdev);
if (ret)
- return ret;
+ goto err_poller_unregister;
p = dev_add_param_uint64(serdev->dev, "polling_interval",
serdev_device_set_polling_interval, NULL,
&serdev->polling_interval, "%llu", serdev);
- return PTR_ERR_OR_ZERO(p);
+ if (IS_ERR(p)) {
+ ret = PTR_ERR(p);
+ goto err_console_close;
+ }
+
+ return 0;
+
+err_console_close:
+ console_close(cdev);
+err_poller_unregister:
+ poller_async_unregister(&serdev->poller);
+err_free_fifo:
+ kfifo_free(serdev->fifo);
+err_free_buf:
+ free(serdev->buf);
+
+ return ret;
}
unsigned int serdev_device_set_baudrate(struct serdev_device *serdev,
--
2.47.3
next prev parent reply other threads:[~2026-02-12 22:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 22:02 [PATCH v2 0/7] Hexagon Geosystems GS05 Board Support Marco Felsch
2026-02-12 22:02 ` Marco Felsch [this message]
2026-02-12 22:02 ` [PATCH v2 2/7] serdev: add serdev_device_close Marco Felsch
2026-02-12 22:02 ` [PATCH v2 3/7] mfd: Add Hexagon EFI driver Marco Felsch
2026-02-12 22:02 ` [PATCH v2 4/7] watchdog: Add Hexagon EFI watchdog driver Marco Felsch
2026-02-12 22:02 ` [PATCH v2 5/7] commands: make run_command variadic Marco Felsch
2026-02-12 22:02 ` [PATCH v2 6/7] treewide: make use of new " Marco Felsch
2026-02-12 22:02 ` [PATCH v2 7/7] ARM: i.MX8MM: add Hexagon Geosystems GS05 Marco Felsch
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=20260212-vmaster-customers-leicageo-system1600-v2-1-f590b7d5b0e9@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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