Blame SOURCES/bz1951049-1-knet-pass-correct-handle-to-knet_handle_compress.patch

06a7ea
commit aa326fb8f87fa0e2db6901db2ccb93cd582dd44f
06a7ea
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
06a7ea
Date:   Tue Apr 6 13:06:05 2021 +0200
06a7ea
06a7ea
    knet: pass correct handle to knet_handle_compress
06a7ea
    
06a7ea
    totemknet_configure_compression was using knet_context
06a7ea
    just to gather the knet handle / instance.
06a7ea
    
06a7ea
    On first time config knet_contex is not initialized till
06a7ea
    much later in the code, passing some random garbage pointers
06a7ea
    to knet_handle_compress, that would crash later trying
06a7ea
    to acquire a mutex lock.
06a7ea
    
06a7ea
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
06a7ea
    Reviewed-by: Jan Friesse <jfriesse@redhat.com>
06a7ea
06a7ea
diff --git a/exec/totemknet.c b/exec/totemknet.c
06a7ea
index 0834e8e..e895256 100644
06a7ea
--- a/exec/totemknet.c
06a7ea
+++ b/exec/totemknet.c
06a7ea
@@ -197,7 +197,7 @@ int totemknet_member_list_rebind_ip (
06a7ea
 
06a7ea
 
06a7ea
 static int totemknet_configure_compression (
06a7ea
-	void *knet_context,
06a7ea
+	struct totemknet_instance *instance,
06a7ea
 	struct totem_config *totem_config);
06a7ea
 
06a7ea
 static void totemknet_start_merge_detect_timeout(
06a7ea
@@ -1154,7 +1154,7 @@ int totemknet_initialize (
06a7ea
 	/* Set up compression */
06a7ea
 	if (strcmp(totem_config->knet_compression_model, "none") != 0) {
06a7ea
 		/* Not fatal, but will log */
06a7ea
-		(void)totemknet_configure_compression(knet_context, totem_config);
06a7ea
+		(void)totemknet_configure_compression(instance, totem_config);
06a7ea
 	}
06a7ea
 
06a7ea
 	knet_handle_setfwd(instance->knet_handle, 1);
06a7ea
@@ -1557,10 +1557,9 @@ int totemknet_member_list_rebind_ip (
06a7ea
 
06a7ea
 
06a7ea
 static int totemknet_configure_compression (
06a7ea
-	void *knet_context,
06a7ea
+	struct totemknet_instance *instance,
06a7ea
 	struct totem_config *totem_config)
06a7ea
 {
06a7ea
-	struct totemknet_instance *instance = (struct totemknet_instance *)knet_context;
06a7ea
 	struct knet_handle_compress_cfg compress_cfg;
06a7ea
 	int res = 0;
06a7ea
 
06a7ea
@@ -1584,7 +1583,7 @@ int totemknet_reconfigure (
06a7ea
 	struct totemknet_instance *instance = (struct totemknet_instance *)knet_context;
06a7ea
 	int res = 0;
06a7ea
 
06a7ea
-	(void)totemknet_configure_compression(knet_context, totem_config);
06a7ea
+	(void)totemknet_configure_compression(instance, totem_config);
06a7ea
 
06a7ea
 #ifdef HAVE_LIBNOZZLE
06a7ea
 	/* Set up nozzle device(s). Return code is ignored, because inability