aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2018-05-23 10:13:20 -0400
committerThomas Hellstrom <thellstrom@vmware.com>2018-05-23 10:15:52 -0400
commitf37230c0ad481091bc136788ff8b37dc86300c6d (patch)
tree0cf34f548f74a0a8053463137a53c2397e41a7ea
parent938ae7259c908ad031da35d551da297640bb640c (diff)
drm/vmwgfx: Fix host logging / guestinfo reading error paths
The error paths were leaking opened channels. Fix by using dedicated error paths. Cc: <stable@vger.kernel.org> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com>
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_msg.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index cdff99211602..21d746bdc922 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -329,8 +329,6 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
329 struct rpc_channel channel; 329 struct rpc_channel channel;
330 char *msg, *reply = NULL; 330 char *msg, *reply = NULL;
331 size_t reply_len = 0; 331 size_t reply_len = 0;
332 int ret = 0;
333
334 332
335 if (!vmw_msg_enabled) 333 if (!vmw_msg_enabled)
336 return -ENODEV; 334 return -ENODEV;
@@ -344,15 +342,14 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
344 return -ENOMEM; 342 return -ENOMEM;
345 } 343 }
346 344
347 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) || 345 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
348 vmw_send_msg(&channel, msg) || 346 goto out_open;
349 vmw_recv_msg(&channel, (void *) &reply, &reply_len) ||
350 vmw_close_channel(&channel)) {
351 DRM_ERROR("Failed to get %s", guest_info_param);
352 347
353 ret = -EINVAL; 348 if (vmw_send_msg(&channel, msg) ||
354 } 349 vmw_recv_msg(&channel, (void *) &reply, &reply_len))
350 goto out_msg;
355 351
352 vmw_close_channel(&channel);
356 if (buffer && reply && reply_len > 0) { 353 if (buffer && reply && reply_len > 0) {
357 /* Remove reply code, which are the first 2 characters of 354 /* Remove reply code, which are the first 2 characters of
358 * the reply 355 * the reply
@@ -369,7 +366,17 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
369 kfree(reply); 366 kfree(reply);
370 kfree(msg); 367 kfree(msg);
371 368
372 return ret; 369 return 0;
370
371out_msg:
372 vmw_close_channel(&channel);
373 kfree(reply);
374out_open:
375 *length = 0;
376 kfree(msg);
377 DRM_ERROR("Failed to get %s", guest_info_param);
378
379 return -EINVAL;
373} 380}
374 381
375 382
@@ -400,15 +407,22 @@ int vmw_host_log(const char *log)
400 return -ENOMEM; 407 return -ENOMEM;
401 } 408 }
402 409
403 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) || 410 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
404 vmw_send_msg(&channel, msg) || 411 goto out_open;
405 vmw_close_channel(&channel)) {
406 DRM_ERROR("Failed to send log\n");
407 412
408 ret = -EINVAL; 413 if (vmw_send_msg(&channel, msg))
409 } 414 goto out_msg;
410 415
416 vmw_close_channel(&channel);
411 kfree(msg); 417 kfree(msg);
412 418
413 return ret; 419 return 0;
420
421out_msg:
422 vmw_close_channel(&channel);
423out_open:
424 kfree(msg);
425 DRM_ERROR("Failed to send log\n");
426
427 return -EINVAL;
414} 428}