]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.16.14/drm-vmwgfx-use-kasprintf.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.16.14 / drm-vmwgfx-use-kasprintf.patch
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
5
6 From: Himanshu Jha <himanshujha199640@gmail.com>
7
8 commit 6073a09210e06f39adabd682c282b3ee14c3d33d upstream.
9
10 Use kasprintf instead of combination of kmalloc and sprintf. Also,
11 remove the local variables used for storing the string length as they
12 are not required now.
13
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>
18
19 ---
20 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 13 +++----------
21 1 file changed, 3 insertions(+), 10 deletions(-)
22
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
26 {
27 struct rpc_channel channel;
28 char *msg, *reply = NULL;
29 - size_t msg_len, reply_len = 0;
30 + size_t reply_len = 0;
31 int ret = 0;
32
33
34 @@ -338,15 +338,12 @@ int vmw_host_get_guestinfo(const char *g
35 if (!guest_info_param || !length)
36 return -EINVAL;
37
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);
41 if (!msg) {
42 DRM_ERROR("Cannot allocate memory to get %s", guest_info_param);
43 return -ENOMEM;
44 }
45
46 - sprintf(msg, "info-get %s", guest_info_param);
47 -
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)
52 {
53 struct rpc_channel channel;
54 char *msg;
55 - int msg_len;
56 int ret = 0;
57
58
59 @@ -398,15 +394,12 @@ int vmw_host_log(const char *log)
60 if (!log)
61 return ret;
62
63 - msg_len = strlen(log) + strlen("log ") + 1;
64 - msg = kzalloc(msg_len, GFP_KERNEL);
65 + msg = kasprintf(GFP_KERNEL, "log %s", log);
66 if (!msg) {
67 DRM_ERROR("Cannot allocate memory for log message\n");
68 return -ENOMEM;
69 }
70
71 - sprintf(msg, "log %s", log);
72 -
73 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
74 vmw_send_msg(&channel, msg) ||
75 vmw_close_channel(&channel)) {