Skip to content

Commit 1eb65c8

Browse files
Mohammed Gamalliuw
authored andcommitted
Drivers: vmbus: Check for channel allocation before looking up relids
relid2channel() assumes vmbus channel array to be allocated when called. However, in cases such as kdump/kexec, not all relids will be reset by the host. When the second kernel boots and if the guest receives a vmbus interrupt during vmbus driver initialization before vmbus_connect() is called, before it finishes, or if it fails, the vmbus interrupt service routine is called which in turn calls relid2channel() and can cause a null pointer dereference. Print a warning and error out in relid2channel() for a channel id that's invalid in the second kernel. Fixes: 8b6a877 ("Drivers: hv: vmbus: Replace the per-CPU channel lists with a global array of channels") Signed-off-by: Mohammed Gamal <mgamal@redhat.com> Reviewed-by: Dexuan Cui <decui@microsoft.com> Link: https://lore.kernel.org/r/20230217204411.212709-1-mgamal@redhat.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent fe15c26 commit 1eb65c8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/hv/connection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ void vmbus_disconnect(void)
409409
*/
410410
struct vmbus_channel *relid2channel(u32 relid)
411411
{
412+
if (vmbus_connection.channels == NULL) {
413+
pr_warn_once("relid2channel: relid=%d: No channels mapped!\n", relid);
414+
return NULL;
415+
}
412416
if (WARN_ON(relid >= MAX_CHANNEL_RELIDS))
413417
return NULL;
414418
return READ_ONCE(vmbus_connection.channels[relid]);

0 commit comments

Comments
 (0)