diff options
author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2015-01-20 10:45:04 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-01-25 12:18:00 -0500 |
commit | 9c3a6f7e476fc4961297fc66b1177f9f8c8dd238 (patch) | |
tree | 7d6f81136568a5b061b4281d747d16a45ce74a73 /drivers/hv | |
parent | c3762b248faf9db2b00b36c0535f79758942069e (diff) |
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: Jason Wang <jasowang@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r-- | drivers/hv/channel_mgmt.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 1d7df2576b1c..704c0e00f8d2 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c | |||
@@ -341,11 +341,10 @@ static void vmbus_process_offer(struct work_struct *work) | |||
341 | if (channel->sc_creation_callback != NULL) | 341 | if (channel->sc_creation_callback != NULL) |
342 | channel->sc_creation_callback(newchannel); | 342 | channel->sc_creation_callback(newchannel); |
343 | 343 | ||
344 | return; | 344 | goto out; |
345 | } | 345 | } |
346 | 346 | ||
347 | free_channel(newchannel); | 347 | goto err_free_chan; |
348 | return; | ||
349 | } | 348 | } |
350 | 349 | ||
351 | /* | 350 | /* |
@@ -364,6 +363,8 @@ static void vmbus_process_offer(struct work_struct *work) | |||
364 | &newchannel->offermsg.offer.if_type, | 363 | &newchannel->offermsg.offer.if_type, |
365 | &newchannel->offermsg.offer.if_instance, | 364 | &newchannel->offermsg.offer.if_instance, |
366 | newchannel); | 365 | newchannel); |
366 | if (!newchannel->device_obj) | ||
367 | goto err_free_chan; | ||
367 | 368 | ||
368 | /* | 369 | /* |
369 | * Add the new device to the bus. This will kick off device-driver | 370 | * 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 | list_del(&newchannel->listentry); | 380 | list_del(&newchannel->listentry); |
380 | spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); | 381 | spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); |
381 | kfree(newchannel->device_obj); | 382 | kfree(newchannel->device_obj); |
382 | 383 | goto err_free_chan; | |
383 | free_channel(newchannel); | ||
384 | } | 384 | } |
385 | out: | ||
386 | return; | ||
387 | err_free_chan: | ||
388 | free_channel(newchannel); | ||
385 | } | 389 | } |
386 | 390 | ||
387 | enum { | 391 | enum { |