Skip to content

Commit

Permalink
staging: unisys: visorbus: my_device_destroy add error handling
Browse files Browse the repository at this point in the history
Add the proper error handling to my_device_destroy so it can be send
back up the stack for further error reporting.

Reported-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: David Kershner <[email protected]>
Reviewed-by: David Binder <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
davidker authored and gregkh committed Jan 3, 2017
1 parent 40fc79f commit e795491
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/staging/unisys/visorbus/visorchipset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,35 +1044,35 @@ my_device_changestate(struct controlvm_message *inmsg)
return err;
}

static void
static int
my_device_destroy(struct controlvm_message *inmsg)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
struct controlvm_message_header *pmsg_hdr = NULL;
u32 bus_no = cmd->destroy_device.bus_no;
u32 dev_no = cmd->destroy_device.dev_no;
struct visor_device *dev_info;
int rc = CONTROLVM_RESP_SUCCESS;
int err;

dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
if (!dev_info) {
rc = -CONTROLVM_RESP_DEVICE_INVALID;
err = -ENODEV;
goto err_respond;
}
if (dev_info->state.created == 0) {
rc = -CONTROLVM_RESP_ALREADY_DONE;
err = -EINVAL;
goto err_respond;
}

if (dev_info->pending_msg_hdr) {
/* only non-NULL if dev is still waiting on a response */
rc = -CONTROLVM_RESP_ID_INVALID_FOR_CLIENT;
err = -EIO;
goto err_respond;
}
if (inmsg->hdr.flags.response_expected == 1) {
pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
if (!pmsg_hdr) {
rc = -CONTROLVM_RESP_KMALLOC_FAILED;
err = -ENOMEM;
goto err_respond;
}

Expand All @@ -1082,11 +1082,12 @@ my_device_destroy(struct controlvm_message *inmsg)
}

chipset_device_destroy(dev_info);
return;
return 0;

err_respond:
if (inmsg->hdr.flags.response_expected == 1)
device_responder(inmsg->hdr.id, &inmsg->hdr, rc);
device_responder(inmsg->hdr.id, &inmsg->hdr, err);
return err;
}

/**
Expand Down

0 comments on commit e795491

Please sign in to comment.