Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5582309img; Wed, 27 Mar 2019 11:07:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzh2t6Wx5f+eMZ8jJF0Zl/PMakmrCZrOKPKojRHDN1TJtu/vAug1VVbesnV4hTh4Kc2v1ld X-Received: by 2002:a62:e418:: with SMTP id r24mr37172707pfh.52.1553710026117; Wed, 27 Mar 2019 11:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710026; cv=none; d=google.com; s=arc-20160816; b=SYogdqkoyEnQnJoutIkkUddX8KMevqxDexsazKNgss7MPG/kofSouv/KCpWh4N1RI/ eapRolUwVjykpJ0/glwYh9FNvLbS6gdtQh//NRbJ6IgJxZaLbExqbFbB1SDS3PGGpKLU +nft/RjF2mpSF2VEZ38ngn82i5RMq+MefqM9/tkKxxcmLjah39HcnqOsdIoGFCIMUSWI UXhoqWoZFm+Xc6KOXMEkp19UNUtq4sOthTt69wBQX23dg4G2ivV67/Yh7WzTpH7KgF0w wlvkrYpeb0u9JXmHYyqED+1Sjq+dEEM/r1801YjCaglM1GOH2vqzS26Hp0TIrCpooIc3 oqRQ== 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=IK0I5WR3VyNEHPvzZKAulGxPVb9n1XhUcVV1VEKfLGQ=; b=LZGO45lq9sJApooNRMs1GcU4sDkVFNKwVSzN6EQ3Tu48HTVCwCI6zr4AvQpF75IKll UKynKvzTku19fp4Ru2nPtdK92VLCIlTrkeO8eHAX/zuKPkvzrFD/x+5yWJq8fM12YGPB MdjAfpuGx3XNjohda4Xur1W4f0A/ePZ2OOmqfuvnIlRoD7YdmtsWCi4z3F5HPdETRMjD nzpAZPAegpa1xArIfHvAhpkCcFi7KnZAzaoifXI9039xkgv6ULC2rODQBMxSPdpTQhjq UsYl9IDMlBD0P6pQ9iTuDeSAAgBmjRT+hLwjVpc1hrgm6B5tZW3EMg1e91pK4Bj+wcf0 tZXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AuFLMFWl; 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 u20si2792902pgi.431.2019.03.27.11.06.50; Wed, 27 Mar 2019 11:07:06 -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=AuFLMFWl; 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 S1730704AbfC0SFV (ORCPT + 99 others); Wed, 27 Mar 2019 14:05:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387660AbfC0SFS (ORCPT ); Wed, 27 Mar 2019 14:05:18 -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 B0AD0217D9; Wed, 27 Mar 2019 18:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709917; bh=3viYCtu81UAAKhQ6NUnzOSWUlL6JSP2ZXor9Eq2z3Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuFLMFWlC531nSadTMsd1Ip4WxFaOxZ6DYlfwwrel1ECN0QPX5aQj9CQ1Vm4zvry9 OXWdVKwHsvAuoYW584hfOXoE0R4agMc/B0iAB+6dmQL2QULLV1c80dXWiNgiwJ4pB8 4wkhMyoVsY4nqoQb1F4Hw+EO8eD4hEwlv/nrEYi0= 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 5.0 112/262] scsi: megaraid_sas: return error when create DMA pool failed Date: Wed, 27 Mar 2019 13:59:27 -0400 Message-Id: <20190327180158.10245-112-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 fcbff83c0097..c9811d1aa007 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4188,6 +4188,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