linux/drivers/infiniband/hw/hfi1
Sebastian Sanchez 45d924571a IB/hfi1: Fix NULL pointer dereference when invalid num_vls is used
When an invalid num_vls is used as a module parameter, the code
execution follows an exception path where the macro dd_dev_err()
expects dd->pcidev->dev not to be NULL in hfi1_init_dd(). This
causes a NULL pointer dereference.

Fix hfi1_init_dd() by initializing dd->pcidev and dd->pcidev->dev
earlier in the code. If a dd exists, then dd->pcidev and
dd->pcidev->dev always exists.

BUG: unable to handle kernel NULL pointer dereference
at 00000000000000f0
IP: __dev_printk+0x15/0x90
Workqueue: events work_for_cpu_fn
RIP: 0010:__dev_printk+0x15/0x90
Call Trace:
 dev_err+0x6c/0x90
 ? hfi1_init_pportdata+0x38d/0x3f0 [hfi1]
 hfi1_init_dd+0xdd/0x2530 [hfi1]
 ? pci_conf1_read+0xb2/0xf0
 ? pci_read_config_word.part.9+0x64/0x80
 ? pci_conf1_write+0xb0/0xf0
 ? pcie_capability_clear_and_set_word+0x57/0x80
 init_one+0x141/0x490 [hfi1]
 local_pci_probe+0x3f/0xa0
 work_for_cpu_fn+0x10/0x20
 process_one_work+0x152/0x350
 worker_thread+0x1cf/0x3e0
 kthread+0xf5/0x130
 ? max_active_store+0x80/0x80
 ? kthread_bind+0x10/0x10
 ? do_syscall_64+0x6e/0x1a0
 ? SyS_exit_group+0x10/0x10
 ret_from_fork+0x35/0x40

Cc: <stable@vger.kernel.org> # 4.9.x
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-03 15:24:47 -04:00
..
affinity.c IB/hfi1: Replace deprecated pci functions with new API 2017-06-27 16:58:11 -04:00
affinity.h IB/hfi1: Name function prototype parameters for affinity module 2017-06-27 16:56:33 -04:00
aspm.h IB/hfi1: Convert timers to use timer_setup() 2017-10-18 11:48:19 -04:00
chip_registers.h RDMA/hfi1: Defer setting VL15 credits to link-up interrupt 2017-06-01 17:04:20 -04:00
chip.c IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit times 2018-02-01 15:43:30 -07:00
chip.h IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit times 2018-02-01 15:43:30 -07:00
common.h IB/hfi1: Eliminate allocation while atomic 2017-10-18 10:12:59 -04:00
debugfs.c IB/hfi1: Show fault stats in both TX and RX directions 2018-02-01 15:43:31 -07:00
debugfs.h IB/hfi1: Add transmit fault injection feature 2017-04-05 14:45:09 -04:00
device.c infiniband: utilize the new cdev_set_parent function 2017-03-21 06:44:33 +01:00
device.h
driver.c IB/hfi1: Fix handling of FECN marked multicast packet 2018-05-03 15:24:44 -04:00
efivar.c IB/hfi1: Check upper-case EFI variables 2017-02-19 09:18:37 -05:00
efivar.h
eprom.c IB/hfi1: Check eeprom config partition validity 2017-09-27 11:10:36 -04:00
eprom.h IB/hfi1: Add ability to read platform config from the EPROM 2016-10-02 08:42:20 -04:00
exp_rcv.c IB/hfi1: Initialize TID lists to avoid crash on cleanup 2017-06-27 16:58:13 -04:00
exp_rcv.h IB/hfi1: Fix bar0 mapping to use write combining 2017-07-31 15:17:54 -04:00
file_ops.c treewide: remove large struct-pass-by-value from tracepoint arguments 2018-03-28 22:55:18 +02:00
firmware.c IB/hfi1: Fix infinite loop in 8051 command error path 2018-01-05 13:34:55 -05:00
hfi.h IB/hfi1: Fix handling of FECN marked multicast packet 2018-05-03 15:24:44 -04:00
init.c IB/hfi1: Fix NULL pointer dereference when invalid num_vls is used 2018-05-03 15:24:47 -04:00
intr.c IB/hfi1: Allow MgmtAllowed on B2B setups 2017-11-13 15:53:56 -05:00
iowait.h IB/hfi1: Remove dependence on qp->s_hdrwords 2018-02-01 15:24:32 -07:00
Kconfig IB/hfi1: Remove HFI1_VERBS_31BIT_PSN option 2017-08-22 14:22:38 -04:00
mad.c IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit times 2018-02-01 15:43:30 -07:00
mad.h IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit times 2018-02-01 15:43:30 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mmu_rb.c mm, mmu_notifier: annotate mmu notifiers with blockable invalidate callbacks 2018-01-31 17:18:38 -08:00
mmu_rb.h IB/hfi1: Don't remove RB entry when not needed. 2017-06-27 16:56:33 -04:00
opa_compat.h IB/hfi1: Document phys port state bits not used in IB 2017-08-22 14:22:37 -04:00
pcie.c IB/hfi1: Fix NULL pointer dereference when invalid num_vls is used 2018-05-03 15:24:47 -04:00
pio_copy.c IB/hfi1: Optimize pio_buf and send_context structs 2016-11-15 16:37:27 -05:00
pio.c IB/hfi1: Convert kzalloc_node and kcalloc to use kcalloc_node 2018-02-01 15:43:32 -07:00
pio.h IB/hfi1: Do not allocate PIO send contexts for VNIC 2017-11-13 15:53:57 -05:00
platform.c IB/hfi1: Only reset QSFP after link up and turn off AOC TX 2017-09-27 11:10:36 -04:00
platform.h IB/hfi1: Define platform_config_table_limits once 2016-12-11 15:29:42 -05:00
qp.c IB/hfi1: Fix a kernel-doc warning 2018-03-13 16:21:14 -04:00
qp.h IB/hfi1: Remove dependence on qp->s_hdrwords 2018-02-01 15:24:32 -07:00
qsfp.c IB/hfi1: Extend i2c timeout 2016-10-02 08:42:13 -04:00
qsfp.h IB/hfi1: Fetch monitor values on-demand for CableInfo query 2016-08-22 14:31:41 -04:00
rc.c Second pull request for 4.16 merge window 2018-02-06 11:09:45 -08:00
ruc.c IB/hfi1: Fix loss of BECN with AHG 2018-05-03 15:24:47 -04:00
sdma_txreq.h
sdma.c Second pull request for 4.16 merge window 2018-02-06 11:09:45 -08:00
sdma.h IB/hfi1: Fix for early release of sdma context 2018-02-01 15:24:32 -07:00
sysfs.c IB/hfi1: Fix incorrect available receive user context count 2017-10-04 15:39:44 -04:00
trace_ctxts.h treewide: remove large struct-pass-by-value from tracepoint arguments 2018-03-28 22:55:18 +02:00
trace_dbg.h IB/hfi1: Separate tracepoints into specific headers 2016-08-02 12:00:54 -04:00
trace_ibhdrs.h IB/hfi1: Remove unnecessary fecn and becn fields 2018-02-01 15:43:29 -07:00
trace_misc.h IB/hfi1: Add traces for TID operations 2017-06-27 16:58:13 -04:00
trace_mmu.h IB/hif1: Remove static tracing from SDMA hot path 2017-08-28 19:12:27 -04:00
trace_rc.h IB/rdmavt, IB/hfi1: Fix timer migration regressions 2017-04-05 14:45:09 -04:00
trace_rx.h IB/hfi1: Add 16B rcvhdr trace support 2018-02-01 15:43:32 -07:00
trace_tx.h IB/hif1: Remove static tracing from SDMA hot path 2017-08-28 19:12:27 -04:00
trace.c IB/hfi1: Remove unnecessary fecn and becn fields 2018-02-01 15:43:29 -07:00
trace.h IB/hfi1: Extend input hdr tracing for packet type 2017-09-27 11:34:13 -04:00
uc.c Second pull request for 4.16 merge window 2018-02-06 11:09:45 -08:00
ud.c IB/hfi1: Fix handling of FECN marked multicast packet 2018-05-03 15:24:44 -04:00
user_exp_rcv.c RDMA: Use u64_to_user_ptr everywhere 2018-03-29 13:42:29 -06:00
user_exp_rcv.h IB/hfi1: Move structure definitions from user_exp_rcv.c to user_exp_rcv.h 2017-08-28 19:12:22 -04:00
user_pages.c IB/hfi1: Virtual Network Interface Controller (VNIC) HW support 2017-04-20 15:19:35 -04:00
user_sdma.c Updates for 4.15 kernel merge window 2017-11-15 14:54:53 -08:00
user_sdma.h IB/hfi1: Convert the macro AHG_HEADER_SET into an inline function 2017-09-27 11:34:13 -04:00
verbs_txreq.c IB/hfi1: Improve local kmem_cache_alloc performance 2017-08-28 19:12:18 -04:00
verbs_txreq.h IB/hfi1: Remove dependence on qp->s_hdrwords 2018-02-01 15:24:32 -07:00
verbs.c IB/uverbs: Extend uverbs_ioctl header with driver_id 2018-03-19 14:45:17 -06:00
verbs.h IB/hfi1: Remove blind constants from 16B update 2018-02-01 15:43:30 -07:00
vnic_main.c IB/hfi1: Do not allocate PIO send contexts for VNIC 2017-11-13 15:53:57 -05:00
vnic_sdma.c IB/hfi1: Improve local kmem_cache_alloc performance 2017-08-28 19:12:18 -04:00
vnic.h IB/hfi1: Add support to receive 16B bypass packets 2017-08-22 14:22:37 -04:00