提交 9c3a6f7e 编写于 作者: V Vitaly Kuznetsov 提交者: Greg Kroah-Hartman

Drivers: hv: check vmbus_device_create() return value in vmbus_process_offer()

vmbus_device_create() result is not being checked in vmbus_process_offer() and
it can fail if kzalloc() fails. Add the check and do minor cleanup to avoid
additional duplication of "free_channel(); return;" block.
Reported-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: NK. Y. Srinivasan <kys@microsoft.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c3762b24
...@@ -341,11 +341,10 @@ static void vmbus_process_offer(struct work_struct *work) ...@@ -341,11 +341,10 @@ static void vmbus_process_offer(struct work_struct *work)
if (channel->sc_creation_callback != NULL) if (channel->sc_creation_callback != NULL)
channel->sc_creation_callback(newchannel); channel->sc_creation_callback(newchannel);
return; goto out;
} }
free_channel(newchannel); goto err_free_chan;
return;
} }
/* /*
...@@ -364,6 +363,8 @@ static void vmbus_process_offer(struct work_struct *work) ...@@ -364,6 +363,8 @@ static void vmbus_process_offer(struct work_struct *work)
&newchannel->offermsg.offer.if_type, &newchannel->offermsg.offer.if_type,
&newchannel->offermsg.offer.if_instance, &newchannel->offermsg.offer.if_instance,
newchannel); newchannel);
if (!newchannel->device_obj)
goto err_free_chan;
/* /*
* Add the new device to the bus. This will kick off device-driver * Add the new device to the bus. This will kick off device-driver
...@@ -379,9 +380,12 @@ static void vmbus_process_offer(struct work_struct *work) ...@@ -379,9 +380,12 @@ static void vmbus_process_offer(struct work_struct *work)
list_del(&newchannel->listentry); list_del(&newchannel->listentry);
spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
kfree(newchannel->device_obj); kfree(newchannel->device_obj);
goto err_free_chan;
free_channel(newchannel);
} }
out:
return;
err_free_chan:
free_channel(newchannel);
} }
enum { enum {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册