Skip to content

Commit

Permalink
misc: ibmasm: Return error on error path
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Anton Vasilyev authored and Jiri Kosina committed Oct 12, 2017
1 parent df47b24 commit f403f85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/misc/ibmasm/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int ibmasm_event_buffer_init(struct service_processor *sp)

buffer = kmalloc(sizeof(struct event_buffer), GFP_KERNEL);
if (!buffer)
return 1;
return -ENOMEM;

buffer->next_index = 0;
buffer->next_serial_number = 1;
Expand Down
6 changes: 4 additions & 2 deletions drivers/misc/ibmasm/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number);
snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number);

if (ibmasm_event_buffer_init(sp)) {
result = ibmasm_event_buffer_init(sp);
if (result) {
dev_err(sp->dev, "Failed to allocate event buffer\n");
goto error_eventbuffer;
}

if (ibmasm_heartbeat_init(sp)) {
result = ibmasm_heartbeat_init(sp);
if (result) {
dev_err(sp->dev, "Failed to allocate heartbeat command\n");
goto error_heartbeat;
}
Expand Down

0 comments on commit f403f85

Please sign in to comment.