Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5615447img; Wed, 27 Mar 2019 11:46:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTDcUU0gw0JDD0RpKQ3kNOKnkMbFt737idaeTrkYf8MvI6M1JsGTEF0LzXnaLMQfPb51mQ X-Received: by 2002:a65:53cb:: with SMTP id z11mr34849193pgr.139.1553712368513; Wed, 27 Mar 2019 11:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712368; cv=none; d=google.com; s=arc-20160816; b=W9wO4pReDlwMsf30re1lPAGSvX1L8UQzRhWYdYw4lZEPp4BOx5hA3J2Gg3SLfZuVGy jN2lGD51CDc5mQsWMgisoMY+ByZMxIq1Hzl6YNeuVkVrn0b50h/VDSDL0eJcfYyxCYOS RrfGoSZd5G9ZFtKYONVYv5GM9cW9Q4ZVMW1PFyszGq0h7nEc7vnELV06Jdp/p8acqp+j W0hFGVobkkRf0toqIfUqQniZxJLnGr4wnWrH9zckQZTjSMuOV1RgRugsor6t+MsneNrO jrnEVZCCP657v+AE+F0n/YkuIOb/hYOjgDedO+LJhWvWRnma+JmPYuNIUfeG3fQ2GqYF qmCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4VeTG58TTun1cM3c9uAZA/1xNFy2mlLdR8xdo4TMuVE=; b=ciFpoYbDZ8yCLiYFkArHL4w+6Y7eu60bbOQrFTe9uUi92Rc6JDGYuHW6oY0K7w1LAm aLRSKnEcs5t0UBelqdqIPEoKOVi6fWFyMX5Msc9/YTffUJQqA394LPyFlGQWMLo6DO/P AQFOFbh2noKdIhEx9ZjQqY/8y79DDoa7uiuW9y32tM0lKJ521NiOTdZWd6It8gYuOYhe /plhcPEPorUApPcuJCiheTZGJnzA5ufW+uJWY1dunXfUGiav+I9Kyu3Wqvudm7Nhjd78 bUpn6XA2zZrUmY5GJ/3ak0BDYNZ6IJi8KpRP8fUZ/gTNaS2m6cInY97f1s0oa7NuYjI9 RQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lIy2y11u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si18963706pfn.122.2019.03.27.11.45.53; Wed, 27 Mar 2019 11:46:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lIy2y11u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391404AbfC0SnM (ORCPT + 99 others); Wed, 27 Mar 2019 14:43:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:39592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390309AbfC0SVk (ORCPT ); Wed, 27 Mar 2019 14:21:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 43B0621738; Wed, 27 Mar 2019 18:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710899; bh=TWb3FiZY2lcX+OVO/8orZQpe9P8p5eQYRP+FMmiza24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIy2y11uxcYk16F5pvb3o3t1o3oFqclbbY7/MgTWO8uFhBGNdMqRclVLeSC+avsgO f9SRfmnepTuahUjymyqOPoqqkk1AzjlhvVYoKWySIKCQaO/MlENxD8L+ra5yupny55 +IEtbXhxgEm2wvMjnh2mUB+N5PxXX/TEcIyyT1mA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Yan , "Martin K . Petersen" , Sasha Levin , megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 36/87] scsi: megaraid_sas: return error when create DMA pool failed Date: Wed, 27 Mar 2019 14:19:49 -0400 Message-Id: <20190327182040.17444-36-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Yan [ 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: [] megasas_free_cmds+0x30/0x70 [] megasas_init_adapter_fusion+0x2f4/0x4d8 [] megasas_init_fw+0x2dc/0x760 [] megasas_probe_one+0x3c0/0xcd8 [] local_pci_probe+0x4c/0xb4 [] pci_device_probe+0x11c/0x14c [] driver_probe_device+0x1ec/0x430 [] __driver_attach+0xa8/0xb0 [] bus_for_each_dev+0x74/0xc8 [] driver_attach+0x28/0x34 [] bus_add_driver+0x16c/0x248 [] driver_register+0x6c/0x138 [] __pci_register_driver+0x5c/0x6c [] megasas_init+0xc0/0x1a8 [] do_one_initcall+0xe8/0x1ec [] kernel_init_freeable+0x1c8/0x284 [] kernel_init+0x1c/0xe4 Signed-off-by: Jason Yan Acked-by: Sumit Saxena Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- 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 5de024a50e15..5b1c37e3913c 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3956,6 +3956,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance) if (megasas_create_frame_pool(instance)) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error creating frame DMA pool\n"); megasas_free_cmds(instance); + return -ENOMEM; } return 0; -- 2.19.1