Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/vmwgfx: Fix host logging / guestinfo reading error paths" failed to apply to 4.16-stable tree

PATCH [email protected] 2 participants 3 messages May 26, 2018 – May 30, 2018

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.16-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

Quoted 1 line

From f37230c0ad481091bc136788ff8b37dc86300c6d Mon Sep 17 00:00:00 2001

From: Thomas Hellstrom <[email protected]>
Date: Wed, 23 May 2018 16:13:20 +0200
Subject: [PATCH] drm/vmwgfx: Fix host logging / guestinfo reading error paths

The error paths were leaking opened channels.
Fix by using dedicated error paths.

drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +31 -17
index cdff99211602..21d746bdc922 100644
@@ -329,8 +329,6 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
 	struct rpc_channel channel;
 	char *msg, *reply = NULL;
 	size_t reply_len = 0;
-	int ret = 0;
-
 
 	if (!vmw_msg_enabled)
 		return -ENODEV;
@@ -344,15 +342,14 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
 		return -ENOMEM;
 	}
 
-	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
-	    vmw_send_msg(&channel, msg) ||
-	    vmw_recv_msg(&channel, (void *) &reply, &reply_len) ||
-	    vmw_close_channel(&channel)) {
-		DRM_ERROR("Failed to get %s", guest_info_param);
+	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
+		goto out_open;
 
-		ret = -EINVAL;
-	}
+	if (vmw_send_msg(&channel, msg) ||
+	    vmw_recv_msg(&channel, (void *) &reply, &reply_len))
+		goto out_msg;
 
+	vmw_close_channel(&channel);
 	if (buffer && reply && reply_len > 0) {
 		/* Remove reply code, which are the first 2 characters of
 		 * the reply
@@ -369,7 +366,17 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
 	kfree(reply);
 	kfree(msg);
 
-	return ret;
+	return 0;
+
+out_msg:
+	vmw_close_channel(&channel);
+	kfree(reply);
+out_open:
+	*length = 0;
+	kfree(msg);
+	DRM_ERROR("Failed to get %s", guest_info_param);
+
+	return -EINVAL;
 }
 
 
@@ -400,15 +407,22 @@ int vmw_host_log(const char *log)
 		return -ENOMEM;
 	}
 
-	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
-	    vmw_send_msg(&channel, msg) ||
-	    vmw_close_channel(&channel)) {
-		DRM_ERROR("Failed to send log\n");
+	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
+		goto out_open;
 
-		ret = -EINVAL;
-	}
+	if (vmw_send_msg(&channel, msg))
+		goto out_msg;
 
+	vmw_close_channel(&channel);
 	kfree(msg);
 
-	return ret;
+	return 0;
+
+out_msg:
+	vmw_close_channel(&channel);
+out_open:
+	kfree(msg);
+	DRM_ERROR("Failed to send log\n");
+
+	return -EINVAL;
 }
#1 lore raw

Hi,

Quoted 8 lines · On 05/26/2018 03:10 PM, [email protected] wrote:

The patch below does not apply to the 4.16-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

The IMO best option is to cherry-pick commit

6073a09210e06 "drm/vmwgfx: Use kasprintf"
by Himanshu Jha. It doesn't fix anything but is small and makes the below patch apply cleanly.

Thanks,
Thomas

Quoted 100 lines

------------------ original commit in Linus's tree ------------------

From f37230c0ad481091bc136788ff8b37dc86300c6d Mon Sep 17 00:00:00 2001
From: Thomas Hellstrom <[email protected]>
Date: Wed, 23 May 2018 16:13:20 +0200
Subject: [PATCH] drm/vmwgfx: Fix host logging / guestinfo reading error paths

The error paths were leaking opened channels.
Fix by using dedicated error paths.

drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +31 -17
index cdff99211602..21d746bdc922 100644
@@ -329,8 +329,6 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
  	struct rpc_channel channel;
  	char *msg, *reply = NULL;
  	size_t reply_len = 0;
-	int ret = 0;
-
 
  	if (!vmw_msg_enabled)
  		return -ENODEV;
@@ -344,15 +342,14 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
  		return -ENOMEM;
  	}
 
-	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
-	    vmw_send_msg(&channel, msg) ||
-	    vmw_recv_msg(&channel, (void *) &reply, &reply_len) ||
-	    vmw_close_channel(&channel)) {
-		DRM_ERROR("Failed to get %s", guest_info_param);
+	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
+		goto out_open;
 
-		ret = -EINVAL;
-	}
+	if (vmw_send_msg(&channel, msg) ||
+	    vmw_recv_msg(&channel, (void *) &reply, &reply_len))
+		goto out_msg;
 
+	vmw_close_channel(&channel);
  	if (buffer && reply && reply_len > 0) {
  		/* Remove reply code, which are the first 2 characters of
  		 * the reply
@@ -369,7 +366,17 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
  	kfree(reply);
  	kfree(msg);
 
-	return ret;
+	return 0;
+
+out_msg:
+	vmw_close_channel(&channel);
+	kfree(reply);
+out_open:
+	*length = 0;
+	kfree(msg);
+	DRM_ERROR("Failed to get %s", guest_info_param);
+
+	return -EINVAL;
  }
 
 
@@ -400,15 +407,22 @@ int vmw_host_log(const char *log)
  		return -ENOMEM;
  	}
 
-	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
-	    vmw_send_msg(&channel, msg) ||
-	    vmw_close_channel(&channel)) {
-		DRM_ERROR("Failed to send log\n");
+	if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
+		goto out_open;
 
-		ret = -EINVAL;
-	}
+	if (vmw_send_msg(&channel, msg))
+		goto out_msg;
 
+	vmw_close_channel(&channel);
  	kfree(msg);
 
-	return ret;
+	return 0;
+
+out_msg:
+	vmw_close_channel(&channel);
+out_open:
+	kfree(msg);
+	DRM_ERROR("Failed to send log\n");
+
+	return -EINVAL;
  }
author maintainer
#2 lore raw
Quoted 10 lines · Thomas Hellstrom

Hi,

Quoted 7 lines · On 05/26/2018 03:10 PM, [email protected] wrote:

The patch below does not apply to the 4.16-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

The IMO best option is to cherry-pick commit

6073a09210e06 "drm/vmwgfx: Use kasprintf"
by Himanshu Jha. It doesn't fix anything but is small and makes the below patch apply cleanly.

That worked, thanks!

greg k-h