Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1700143 > unrolled thread
| Started by | Anton Vasilyev <vasilyev@ispras.ru> |
|---|---|
| First post | 2017-07-31 18:00 +0200 |
| Last post | 2017-07-31 18:30 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] misc: Return error on error path Anton Vasilyev <vasilyev@ispras.ru> - 2017-07-31 18:00 +0200
Re: [PATCH] misc: Return error on error path Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-07-31 18:30 +0200
| From | Anton Vasilyev <vasilyev@ispras.ru> |
|---|---|
| Date | 2017-07-31 18:00 +0200 |
| Subject | [PATCH] misc: Return error on error path |
| Message-ID | <u9lgS-85O-7@gated-at.bofh.it> |
If ibmasm_event_buffer_init() or ibmasm_heartbeat_init() fails,
then ibmasm_init_one() release all resources and return 0 on error path.
The patch adds corresponding error for fails.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
---
drivers/misc/ibmasm/module.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index c5a456b..ba76405 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -96,11 +96,13 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
if (ibmasm_event_buffer_init(sp)) {
dev_err(sp->dev, "Failed to allocate event buffer\n");
+ result = -ENOMEM;
goto error_eventbuffer;
}
if (ibmasm_heartbeat_init(sp)) {
dev_err(sp->dev, "Failed to allocate heartbeat command\n");
+ result = -ENOMEM;
goto error_heartbeat;
}
--
2.7.4
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-07-31 18:30 +0200 |
| Message-ID | <u9lJU-8uS-13@gated-at.bofh.it> |
| In reply to | #1700143 |
On Mon, Jul 31, 2017 at 6:48 PM, Anton Vasilyev <vasilyev@ispras.ru> wrote:
> If ibmasm_event_buffer_init() or ibmasm_heartbeat_init() fails,
> then ibmasm_init_one() release all resources and return 0 on error path.
>
> The patch adds corresponding error for fails.
>
> Found by Linux Driver Verification project (linuxtesting.org).
To me looks better to
- return 1;
+ return -ENOMEM;
in event.c, and then...
> if (ibmasm_event_buffer_init(sp)) {
> dev_err(sp->dev, "Failed to allocate event buffer\n");
> + result = -ENOMEM;
> goto error_eventbuffer;
> }
result = ibmasm_event_buffer_init(sp);
if (result) {
...
}
> if (ibmasm_heartbeat_init(sp)) {
> dev_err(sp->dev, "Failed to allocate heartbeat command\n");
> + result = -ENOMEM;
> goto error_heartbeat;
> }
Ditto.
--
With Best Regards,
Andy Shevchenko
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web