From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/infiniband/core/iwcm.c

Change-Id: I0bad70a2b0f1de856668b19f0a56068eb1834100
---
 drivers/infiniband/core/iwcm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -58,6 +58,9 @@
 MODULE_AUTHOR("Tom Tucker");
 MODULE_DESCRIPTION("iWARP CM");
 MODULE_LICENSE("Dual BSD/GPL");
+#ifdef RETPOLINE_MLNX
+MODULE_INFO(retpoline, "Y");
+#endif
 
 static const char * const iwcm_rej_reason_strs[] = {
 	[ECONNRESET]			= "reset by remote host",
@@ -102,6 +105,7 @@ struct iwcm_work {
 
 static unsigned int default_backlog = 256;
 
+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
 static struct ctl_table_header *iwcm_ctl_table_hdr;
 static struct ctl_table iwcm_ctl_table[] = {
 	{
@@ -111,8 +115,12 @@ static struct ctl_table iwcm_ctl_table[]
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+#ifndef HAVE_REMOVE_SENTINEL_FROM_CTL_TABLE
+	{ }
+#endif
 };
 
+#endif
 /*
  * The following services provide a mechanism for pre-allocating iwcm_work
  * elements.  The design pre-allocates them  based on the cm_id type:
@@ -479,6 +487,7 @@ static void iw_cm_check_wildcard(struct
 			cm4_outaddr->sin_addr = cm4_addr->sin_addr;
 		}
 	} else {
+#if IS_ENABLED(CONFIG_IPV6)
 		struct sockaddr_in6 *pm6_addr = (struct sockaddr_in6 *)pm_addr;
 
 		if (ipv6_addr_type(&pm6_addr->sin6_addr) == IPV6_ADDR_ANY) {
@@ -489,6 +498,7 @@ static void iw_cm_check_wildcard(struct
 
 			cm6_outaddr->sin6_addr = cm6_addr->sin6_addr;
 		}
+#endif
 	}
 }
 
@@ -1191,18 +1201,22 @@ static int __init iw_cm_init(void)
 	if (!iwcm_wq)
 		goto err_alloc;
 
+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
 	iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm",
 						 iwcm_ctl_table);
 	if (!iwcm_ctl_table_hdr) {
 		pr_err("iw_cm: couldn't register sysctl paths\n");
 		goto err_sysctl;
 	}
+#endif
 
 	rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
 	return 0;
 
+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
 err_sysctl:
 	destroy_workqueue(iwcm_wq);
+#endif
 err_alloc:
 	iwpm_exit(RDMA_NL_IWCM);
 	return -ENOMEM;
@@ -1210,7 +1224,9 @@ err_alloc:
 
 static void __exit iw_cm_cleanup(void)
 {
+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
 	rdma_nl_unregister(RDMA_NL_IWCM);
+#endif
 	unregister_net_sysctl_table(iwcm_ctl_table_hdr);
 	destroy_workqueue(iwcm_wq);
 	iwpm_exit(RDMA_NL_IWCM);
