From patchwork Sat Apr 15 18:55:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9682375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83F9360138 for ; Sat, 15 Apr 2017 18:57:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7658925223 for ; Sat, 15 Apr 2017 18:57:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B1F328305; Sat, 15 Apr 2017 18:57:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFAE725E13 for ; Sat, 15 Apr 2017 18:57:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754390AbdDOS5s (ORCPT ); Sat, 15 Apr 2017 14:57:48 -0400 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:38016 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932073AbdDOS5U (ORCPT ); Sat, 15 Apr 2017 14:57:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cnexlabs.onmicrosoft.com; s=selector1-cnexlabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xNTmKH1G7gVubrNQ8JXbN/xOIBUrdVCfgz1As0/diCo=; b=RfXVWQZNpshsUKgNi5k2VYC795BEfoHeuVNmTfTzDeP0LVb6pcIkxMkWib8TB1aTj8G3XL3yQrUVzN/zg617/rpM0/dHm4l42D/U6bI05QxuNH5F0LoT+Yg4b+fa0o3FVBB77K5G9pLkNRzfgWgrIkxrHMoDj+N6cqCVFkU6Xzc= Authentication-Results: fb.com; dkim=none (message not signed) header.d=none; fb.com; dmarc=none action=none header.from=cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Sat, 15 Apr 2017 18:56:40 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , Dan Carpenter , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 19/19] lightnvm: fix some error code in pblk-init.c Date: Sat, 15 Apr 2017 20:55:53 +0200 Message-ID: <20170415185553.16098-20-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170415185553.16098-1-matias@cnexlabs.com> References: <20170415185553.16098-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: AM5PR0701CA0069.eurprd07.prod.outlook.com (10.169.145.159) To CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) X-MS-Office365-Filtering-Correlation-Id: b19791f3-a025-47cc-194d-08d484312792 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 3:VEY971JgRfgrmWh2bH4+C+LGO8+G0eWMVqdxaZ3mr1dxkE31n2L3qMCIthkPh+iE0F8DoVhLstaBsKhuifGWZd0dCN3qBAxurPZz0pFqgtdruxURw7dhrCxnqvq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1b+jx35MbOY5xHMyq6QP6f74GiLM/K38ZjazOZaP1FLGNCaCAas/5XM1Nuo5qoA+dc7L5UXDL4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201703061421075)(20161123555025)(6072148); SRVR:CY4PR06MB2774; BCL:0; PCL:0; RULEID:; SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 4:i2zzwAQTgngxe/GCSaxWwpSbIzhi0m8Nr4A+onYzJxO0pwY+lboRTqpLmgCsh0ZMmSIUgF0h1p6SBOe1Z9IFDWiRCv+MMPhGbvA94fZ0vPnK0pPhbRkr1T7LI9b4UoFKlre/on+LI/cIgAnDJhDpX6f1kht0WfY1vW0EL0uha84U55VpC2bWJLyEd6oaGYFREK1TYc2JPe8/YnFTkkuurTFJwCdk5gjmZpbkuZxaNXgWYfcOt6IBMqlcXVMfm7TSijl+0xFoF5Dv4uEvF3Jo0/OcaSTUGfqPAeRyPc0aFMe062oxVKJXXMrxViLaTxLyysFhUE1buk3Nrq9t7Dnp9t/6EAkSPuI2bhP/ti8i5IK0QrRg7KnU+s3/BQl2HfcnIu7POvIkrjG3ElCep29trH9p60UgUwVl6br4spwQIoHxRhCFlOs1quGAocuuEej2j3+cldAFjjzC01mAoTV7uWKmEvFvDqY2oQKG6dQbn0imYBptwmCWqNuPRI+T1hLrZTObroSPiwIzYAlvoiIobpjlEmNEbkSfQo/sXIS+f/nd1Z1ZF1dFhh2vKqbNYbgIW2JlxsT/vhRPacy4MI4kOacYQj3P467sDxdoDt1oCGBi4sPxlBRljUrF+SXwmiT7IvnqSWGWUxw6cMqbUrdRWXI8g0gV+ldNuTdElys3SMbMmrRJdKK/AUc4YPn1mMQA2iBL1P6n/FZ2qju/+SCzLrJGfvEUetatK70Jgpul1Wk= X-Forefront-PRVS: 02788FF38E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39450400003)(86362001)(305945005)(1076002)(6916009)(6666003)(25786009)(2950100002)(6486002)(2906002)(3846002)(6116002)(2870700001)(54906002)(189998001)(53936002)(53416004)(107886003)(110136004)(5660300001)(38730400002)(50986999)(76176999)(2351001)(4326008)(66066001)(5820100001)(23676002)(81166006)(47776003)(42186005)(36756003)(33646002)(50226002)(8676002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR06MB2774; H:skyninja.cnexlabs.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA2TUIyNzc0OzIzOnQ5Q1MwU2ZUWVlCV25iUDlyYm10NjYyRFRW?= =?utf-8?B?Y2hFRFZhbnB6TXdRYUcraW1FaEZDSWV5ZVBJU201ZkVzaXpjZ2VWOGx0emxt?= =?utf-8?B?cnN2LzZqc2dCa0hENDUxM1plTG0vaUtzb1ZLUDcyMmxUVzdiU2p2Y2hpcUZE?= =?utf-8?B?eTdKTDNVNitZZFMxM1A5YTV5REZ5UDFNSXlZRnVFWG9WenB6ay9qSWIrTC9N?= =?utf-8?B?MzFFNDZlMjBiQlZ6RUNCQnRBR0xVSHF0aWhBajAxSUYvcjRqWWh1Y3I2cWJU?= =?utf-8?B?Vk02eFNjbEh2bzZyamhFeWtuMi9NWlpCOXI4QlVXcWpBNmVFWU40d0pJZElr?= =?utf-8?B?bFJYNWZ5YS9lUTJONlVhYitJSUtrSElVRXdKa3NEOTFoWElBUlQ3K2pzZjh5?= =?utf-8?B?em1IZUZYYlhCdkFUeFByL25OdGVyKzJLSFZQTnBWUUh0L0IxVkZQWjNhVVNh?= =?utf-8?B?QXdwNWNRN29mNG0xZ05oU3J4NjlNYlp5SENjM3NOTHFwWWJ2Szg1QVJqRHgx?= =?utf-8?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pvDPjCufQ9dWpH/VRg== X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2017 18:56:40.7964 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2774 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Carpenter There were a bunch of places in pblk_lines_init() where we didn't set an error code. And in pblk_writer_init() we accidentally return 1 instead of a correct error code, which would result in a Oops later. Fixes: 11a5d6fdf919 ("lightnvm: physical block device (pblk) target") Signed-off-by: Dan Carpenter Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-init.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 94653b1..3996e4b 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -543,7 +543,7 @@ static int pblk_lines_init(struct pblk *pblk) long nr_bad_blks, nr_meta_blks, nr_free_blks; int bb_distance; int i; - int ret = 0; + int ret; lm->sec_per_line = geo->sec_per_blk * geo->nr_luns; lm->blk_per_line = geo->nr_luns; @@ -638,12 +638,16 @@ static int pblk_lines_init(struct pblk *pblk) } l_mg->bb_template = kzalloc(lm->sec_bitmap_len, GFP_KERNEL); - if (!l_mg->bb_template) + if (!l_mg->bb_template) { + ret = -ENOMEM; goto fail_free_meta; + } l_mg->bb_aux = kzalloc(lm->sec_bitmap_len, GFP_KERNEL); - if (!l_mg->bb_aux) + if (!l_mg->bb_aux) { + ret = -ENOMEM; goto fail_free_bb_template; + } bb_distance = (geo->nr_luns) * geo->sec_per_pl; for (i = 0; i < lm->sec_per_line; i += bb_distance) @@ -667,8 +671,10 @@ static int pblk_lines_init(struct pblk *pblk) pblk->lines = kcalloc(l_mg->nr_lines, sizeof(struct pblk_line), GFP_KERNEL); - if (!pblk->lines) + if (!pblk->lines) { + ret = -ENOMEM; goto fail_free_bb_aux; + } nr_free_blks = 0; for (i = 0; i < l_mg->nr_lines; i++) { @@ -682,8 +688,10 @@ static int pblk_lines_init(struct pblk *pblk) spin_lock_init(&line->lock); nr_bad_blks = pblk_bb_line(pblk, line); - if (nr_bad_blks < 0 || nr_bad_blks > lm->blk_per_line) + if (nr_bad_blks < 0 || nr_bad_blks > lm->blk_per_line) { + ret = -EINVAL; goto fail_free_lines; + } line->blk_in_line = lm->blk_per_line - nr_bad_blks; if (line->blk_in_line < lm->min_blk_line) { @@ -733,7 +741,7 @@ static int pblk_writer_init(struct pblk *pblk) pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t"); if (IS_ERR(pblk->writer_ts)) { pr_err("pblk: could not allocate writer kthread\n"); - return 1; + return PTR_ERR(pblk->writer_ts); } return 0;