1 From 6073a09210e06f39adabd682c282b3ee14c3d33d Mon Sep 17 00:00:00 2001
2 From: Himanshu Jha <himanshujha199640@gmail.com>
3 Date: Thu, 22 Mar 2018 10:33:03 +0100
4 Subject: drm/vmwgfx: Use kasprintf
6 From: Himanshu Jha <himanshujha199640@gmail.com>
8 commit 6073a09210e06f39adabd682c282b3ee14c3d33d upstream.
10 Use kasprintf instead of combination of kmalloc and sprintf. Also,
11 remove the local variables used for storing the string length as they
14 Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
15 Reviewed-by: Sinclair Yeh <syeh@vmware.com>
16 Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 13 +++----------
21 1 file changed, 3 insertions(+), 10 deletions(-)
23 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
24 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
25 @@ -328,7 +328,7 @@ int vmw_host_get_guestinfo(const char *g
27 struct rpc_channel channel;
28 char *msg, *reply = NULL;
29 - size_t msg_len, reply_len = 0;
30 + size_t reply_len = 0;
34 @@ -338,15 +338,12 @@ int vmw_host_get_guestinfo(const char *g
35 if (!guest_info_param || !length)
38 - msg_len = strlen(guest_info_param) + strlen("info-get ") + 1;
39 - msg = kzalloc(msg_len, GFP_KERNEL);
40 + msg = kasprintf(GFP_KERNEL, "info-get %s", guest_info_param);
42 DRM_ERROR("Cannot allocate memory to get %s", guest_info_param);
46 - sprintf(msg, "info-get %s", guest_info_param);
48 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
49 vmw_send_msg(&channel, msg) ||
50 vmw_recv_msg(&channel, (void *) &reply, &reply_len) ||
51 @@ -388,7 +385,6 @@ int vmw_host_log(const char *log)
53 struct rpc_channel channel;
59 @@ -398,15 +394,12 @@ int vmw_host_log(const char *log)
63 - msg_len = strlen(log) + strlen("log ") + 1;
64 - msg = kzalloc(msg_len, GFP_KERNEL);
65 + msg = kasprintf(GFP_KERNEL, "log %s", log);
67 DRM_ERROR("Cannot allocate memory for log message\n");
71 - sprintf(msg, "log %s", log);
73 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
74 vmw_send_msg(&channel, msg) ||
75 vmw_close_channel(&channel)) {