public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jason Yan <yanaijie@huawei.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Sasha Levin <sashal@kernel.org>,
	megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 3.18 18/41] scsi: megaraid_sas: return error when create DMA pool failed
Date: Wed, 27 Mar 2019 14:24:55 -0400	[thread overview]
Message-ID: <20190327182518.19394-18-sashal@kernel.org> (raw)
In-Reply-To: <20190327182518.19394-1-sashal@kernel.org>

From: Jason Yan <yanaijie@huawei.com>

[ Upstream commit bcf3b67d16a4c8ffae0aa79de5853435e683945c ]

when create DMA pool for cmd frames failed, we should return -ENOMEM,
instead of 0.
In some case in:

    megasas_init_adapter_fusion()

    -->megasas_alloc_cmds()
       -->megasas_create_frame_pool
          create DMA pool failed,
        --> megasas_free_cmds() [1]

    -->megasas_alloc_cmds_fusion()
       failed, then goto fail_alloc_cmds.
    -->megasas_free_cmds() [2]

we will call megasas_free_cmds twice, [1] will kfree cmd_list,
[2] will use cmd_list.it will cause a problem:

Unable to handle kernel NULL pointer dereference at virtual address
00000000
pgd = ffffffc000f70000
[00000000] *pgd=0000001fbf893003, *pud=0000001fbf893003,
*pmd=0000001fbf894003, *pte=006000006d000707
Internal error: Oops: 96000005 [#1] SMP
 Modules linked in:
 CPU: 18 PID: 1 Comm: swapper/0 Not tainted
 task: ffffffdfb9290000 ti: ffffffdfb923c000 task.ti: ffffffdfb923c000
 PC is at megasas_free_cmds+0x30/0x70
 LR is at megasas_free_cmds+0x24/0x70
 ...
 Call trace:
 [<ffffffc0005b779c>] megasas_free_cmds+0x30/0x70
 [<ffffffc0005bca74>] megasas_init_adapter_fusion+0x2f4/0x4d8
 [<ffffffc0005b926c>] megasas_init_fw+0x2dc/0x760
 [<ffffffc0005b9ab0>] megasas_probe_one+0x3c0/0xcd8
 [<ffffffc0004a5abc>] local_pci_probe+0x4c/0xb4
 [<ffffffc0004a5c40>] pci_device_probe+0x11c/0x14c
 [<ffffffc00053a5e4>] driver_probe_device+0x1ec/0x430
 [<ffffffc00053a92c>] __driver_attach+0xa8/0xb0
 [<ffffffc000538178>] bus_for_each_dev+0x74/0xc8
  [<ffffffc000539e88>] driver_attach+0x28/0x34
 [<ffffffc000539a18>] bus_add_driver+0x16c/0x248
 [<ffffffc00053b234>] driver_register+0x6c/0x138
 [<ffffffc0004a5350>] __pci_register_driver+0x5c/0x6c
 [<ffffffc000ce3868>] megasas_init+0xc0/0x1a8
 [<ffffffc000082a58>] do_one_initcall+0xe8/0x1ec
 [<ffffffc000ca7be8>] kernel_init_freeable+0x1c8/0x284
 [<ffffffc0008d90b8>] kernel_init+0x1c/0xe4

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 1ff0ece87644..24cc8786ff06 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3743,6 +3743,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
 	if (megasas_create_frame_pool(instance)) {
 		printk(KERN_DEBUG "megasas: Error creating frame DMA pool\n");
 		megasas_free_cmds(instance);
+		return -ENOMEM;
 	}
 
 	return 0;
-- 
2.19.1


  parent reply	other threads:[~2019-03-27 18:26 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27 18:24 [PATCH AUTOSEL 3.18 01/41] i2c: sis630: correct format strings Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 02/41] tracing: kdb: Fix ftdump to not sleep Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 03/41] sysctl: handle overflow for file-max Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 04/41] mm/cma.c: cma_declare_contiguous: correct err handling Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 05/41] mm/vmalloc.c: fix kernel BUG at mm/vmalloc.c:512! Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 06/41] mm/slab.c: kmemleak no scan alien caches Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 07/41] ocfs2: fix a panic problem caused by o2cb_ctl Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 08/41] cifs: use correct format characters Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 09/41] dm thin: add sanity checks to thin-pool and external snapshot creation Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 10/41] cifs: Fix NULL pointer dereference of devname Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 11/41] fs: fix guard_bio_eod to check for real EOD errors Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 12/41] tools lib traceevent: Fix buffer overflow in arg_eval Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 13/41] scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 14/41] ARM: 8840/1: use a raw_spinlock_t in unwind Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 15/41] mmc: omap: fix the maximum timeout setting Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 16/41] e1000e: Fix -Wformat-truncation warnings Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 17/41] IB/mlx4: Increase the timeout for CM cache Sasha Levin
2019-03-27 18:24 ` Sasha Levin [this message]
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 19/41] SoC: imx-sgtl5000: add missing put_device() Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 20/41] leds: lp55xx: fix null deref on firmware load failure Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 21/41] kprobes: Prohibit probing on bsearch() Sasha Levin
2019-03-27 18:24 ` [PATCH AUTOSEL 3.18 22/41] ARM: 8833/1: Ensure that NEON code always compiles with Clang Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 23/41] ALSA: PCM: check if ops are defined before suspending PCM Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 24/41] bcache: fix input overflow to cache set sysfs file io_error_halflife Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 25/41] bcache: fix input overflow to sequential_cutoff Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 26/41] bcache: improve sysfs_strtoul_clamp() Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 27/41] fbdev: fbmem: fix memory access if logo is bigger than the screen Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 28/41] cdrom: Fix race condition in cdrom_sysctl_register Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 29/41] e1000e: fix cyclic resets at link up with active tx Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 30/41] locking/lockdep: Add debug_locks check in __lock_downgrade() Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 31/41] tty: increase the default flip buffer limit to 2*640K Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 32/41] media: mt9m111: set initial frame size other than 0x0 Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 33/41] hwrng: virtio - Avoid repeated init of completion Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 34/41] Bluetooth: Verify that l2cap_get_conf_opt provides large enough buffer Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 35/41] hpet: Fix missing '=' character in the __setup() code of hpet_mmap_enable Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 36/41] dmaengine: imx-dma: fix warning comparison of distinct pointer types Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 37/41] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 38/41] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 39/41] x86/build: Mark per-CPU symbols as absolute explicitly for LLD Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 40/41] dmaengine: tegra: avoid overflow of byte tracking Sasha Levin
2019-03-27 18:25 ` [PATCH AUTOSEL 3.18 41/41] drm/dp/mst: Configure no_stop_bit correctly for remote i2c xfers Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190327182518.19394-18-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=megaraidlinux.pdl@broadcom.com \
    --cc=stable@vger.kernel.org \
    --cc=yanaijie@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox