From 811fa97ef392bb9a0bb2718c07ec9cb871ab37a5 Mon Sep 17 00:00:00 2001 From: Pradeep Gopanapalli Date: Mon, 28 Nov 2016 23:58:20 +0000 Subject: [PATCH] xsigo: Fix crash in accessing xve proc l2 entries Orabug: 25165085 When accessing l2tables using /proc/driver/xve/devices/ system panics if path is created and there is no associated Transmit QP. Added a check for validating tx structure before using it. Reported-by: Jie zhu Signed-off-by: Pradeep Gopanapalli Reviewed-by: sajid zia --- drivers/infiniband/ulp/xsigo/xscore/Makefile | 2 +- drivers/infiniband/ulp/xsigo/xsvhba/Makefile | 2 +- drivers/infiniband/ulp/xsigo/xsvnic/Makefile | 2 +- drivers/infiniband/ulp/xsigo/xve/Makefile | 2 +- drivers/infiniband/ulp/xsigo/xve/xve.h | 8 ++++++++ drivers/infiniband/ulp/xsigo/xve/xve_stats.c | 7 ++----- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/ulp/xsigo/xscore/Makefile b/drivers/infiniband/ulp/xsigo/xscore/Makefile index 2a76c98dd60c..bc52ca670739 100644 --- a/drivers/infiniband/ulp/xsigo/xscore/Makefile +++ b/drivers/infiniband/ulp/xsigo/xscore/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_INFINIBAND_XSCORE) := xscore.o xscore-y := xscore_impl.o xs_ud.o xscore_api.o xsmp.o \ xscore_stats.o xscore_uadm.o -ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8040\" +ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8041\" ccflags-y += -DRDMA_PORT_LINK_LAYER_CHANGES -DHAS_SKB_ACCESS_FUNCTIONS ccflags-y += -DSCSI_STRUCT_CHANGES -DSCSI_TIMEOUT_CHANGES -DLLE ccflags-y += -DXG_FRAG_SIZE_PRESENT -DXG_FRAG_PAGE_PRESENT diff --git a/drivers/infiniband/ulp/xsigo/xsvhba/Makefile b/drivers/infiniband/ulp/xsigo/xsvhba/Makefile index 5505cc964e9c..715c949f1554 100644 --- a/drivers/infiniband/ulp/xsigo/xsvhba/Makefile +++ b/drivers/infiniband/ulp/xsigo/xsvhba/Makefile @@ -3,7 +3,7 @@ xsvhba-y := vhba_main.o vhba_xsmp.o vhba_create.o vhba_init.o vhba_delete.o \ vhba_attr.o vhba_wq.o vhba_proc.o vhba_stats.o vhba_ib.o \ vhba_scsi_intf.o vhba_align.o -ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8040\" +ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8041\" ccflags-y += -DRDMA_PORT_LINK_LAYER_CHANGES -DHAS_SKB_ACCESS_FUNCTIONS ccflags-y += -DSCSI_STRUCT_CHANGES -DSCSI_TIMEOUT_CHANGES -DLLE ccflags-y += -DXG_FRAG_SIZE_PRESENT -DXG_FRAG_PAGE_PRESENT diff --git a/drivers/infiniband/ulp/xsigo/xsvnic/Makefile b/drivers/infiniband/ulp/xsigo/xsvnic/Makefile index c06a251987db..e59d925db619 100644 --- a/drivers/infiniband/ulp/xsigo/xsvnic/Makefile +++ b/drivers/infiniband/ulp/xsigo/xsvnic/Makefile @@ -1,7 +1,7 @@ obj-$(CONFIG_INFINIBAND_XSVNIC) := xsvnic.o xsvnic-y := xsvnic_main.o xsvnic_stats.o -ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8040\" +ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8041\" ccflags-y += -DRDMA_PORT_LINK_LAYER_CHANGES -DHAS_SKB_ACCESS_FUNCTIONS ccflags-y += -DSCSI_STRUCT_CHANGES -DSCSI_TIMEOUT_CHANGES -DLLE ccflags-y += -DXG_FRAG_SIZE_PRESENT -DXG_FRAG_PAGE_PRESENT diff --git a/drivers/infiniband/ulp/xsigo/xve/Makefile b/drivers/infiniband/ulp/xsigo/xve/Makefile index 9c3e03731ccf..57b401bc2729 100644 --- a/drivers/infiniband/ulp/xsigo/xve/Makefile +++ b/drivers/infiniband/ulp/xsigo/xve/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_INFINIBAND_XVE) := xve.o xve-y := xve_main.o xve_verbs.o xve_multicast.o xve_ib.o xve_tables.o \ xve_ethtool.o xve_cm.o xve_stats.o -ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8040\" +ccflags-y += -DXSIGO_LOCAL_VERSION=\"6.0.r8041\" ccflags-y += -DRDMA_PORT_LINK_LAYER_CHANGES -DHAS_SKB_ACCESS_FUNCTIONS ccflags-y += -DSCSI_STRUCT_CHANGES -DSCSI_TIMEOUT_CHANGES -DLLE ccflags-y += -DXG_FRAG_SIZE_PRESENT -DXG_FRAG_PAGE_PRESENT diff --git a/drivers/infiniband/ulp/xsigo/xve/xve.h b/drivers/infiniband/ulp/xsigo/xve/xve.h index fc4998276c9d..baab63794528 100644 --- a/drivers/infiniband/ulp/xsigo/xve/xve.h +++ b/drivers/infiniband/ulp/xsigo/xve/xve.h @@ -1089,6 +1089,14 @@ static inline int xve_cm_up(struct xve_path *path) return test_bit(XVE_FLAG_OPER_UP, &path->cm_ctx_tx->flags); } +static inline char *xve_cm_txstate(struct xve_cm_ctx *tx) +{ + if (test_bit(XVE_FLAG_OPER_UP, &tx->flags)) + return "Connected"; + else + return "Not Connected"; +} + static inline struct xve_cm_ctx *xve_get_cmctx(struct xve_path *path) { return path->cm_ctx_common; diff --git a/drivers/infiniband/ulp/xsigo/xve/xve_stats.c b/drivers/infiniband/ulp/xsigo/xve/xve_stats.c index 537d253c9ae4..791c219755b8 100755 --- a/drivers/infiniband/ulp/xsigo/xve/xve_stats.c +++ b/drivers/infiniband/ulp/xsigo/xve/xve_stats.c @@ -322,7 +322,6 @@ static int xve_proc_l2_read_device(struct seq_file *m, void *data) k = 0; hlist_for_each_entry_safe(fwt_entry, n, head, hlist) { if (xve_fwt_entry_valid(xve_fwt, fwt_entry) == true) { - char *cmstr = "Not Connected"; u16 printed = 0; struct xve_cm_ctx *tx = NULL, *rx = NULL; @@ -337,9 +336,6 @@ static int xve_proc_l2_read_device(struct seq_file *m, void *data) tx = xve_cmtx_get(fwt_entry->path); rx = xve_cmrx_get(fwt_entry->path); - if (test_bit(XVE_FLAG_OPER_UP, - &tx->flags)) - cmstr = "Connected"; if (rx) rx_rate = rx->stats.rx_rate; if (tx) { @@ -354,7 +350,8 @@ static int xve_proc_l2_read_device(struct seq_file *m, void *data) ALIGN_TO_FF(smac[3]), ALIGN_TO_FF(smac[4]), ALIGN_TO_FF(smac[5]), - tmp_buf + 8, cmstr, + tmp_buf + 8, + xve_cm_txstate(tx), tx->qp ? tx->qp-> qp_num : 0, tx->version, -- 2.50.1