Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64b7faf9 authored by Dexuan Cui's avatar Dexuan Cui Committed by Greg Kroah-Hartman
Browse files

Drivers: hv: vmbus: do sanity check of channel state in vmbus_close_internal()



This fixes an incorrect assumption of channel state in the function.

Signed-off-by: default avatarDexuan Cui <decui@microsoft.com>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 63d55b2a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -512,6 +512,18 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
	tasklet = hv_context.event_dpc[channel->target_cpu];
	tasklet_disable(tasklet);

	/*
	 * In case a device driver's probe() fails (e.g.,
	 * util_probe() -> vmbus_open() returns -ENOMEM) and the device is
	 * rescinded later (e.g., we dynamically disble an Integrated Service
	 * in Hyper-V Manager), the driver's remove() invokes vmbus_close():
	 * here we should skip most of the below cleanup work.
	 */
	if (channel->state != CHANNEL_OPENED_STATE) {
		ret = -EINVAL;
		goto out;
	}

	channel->state = CHANNEL_OPEN_STATE;
	channel->sc_creation_callback = NULL;
	/* Stop callback and cancel the timer asap */