From patchwork Thu Feb 11 13:49:13 2016 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: 8279471 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D10D5BEEE5 for ; Thu, 11 Feb 2016 13:49:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EABF20380 for ; Thu, 11 Feb 2016 13:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C57DE201CD for ; Thu, 11 Feb 2016 13:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753227AbcBKNtZ (ORCPT ); Thu, 11 Feb 2016 08:49:25 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36164 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753173AbcBKNtW (ORCPT ); Thu, 11 Feb 2016 08:49:22 -0500 Received: by mail-wm0-f49.google.com with SMTP id p63so73942397wmp.1 for ; Thu, 11 Feb 2016 05:49:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=4OYTehG+Bhg90QqYjzogAsU5vsby1VxPsdvY6UZrUog=; b=lnTFn/8DYnjgwINSl1QL4zeKxZ19V4vz7Vp7U2bBgGkGPuJkcWwACVN/t3ZaX/jvLX GAThsORToDuJZZB8ZcPZPtOYt77YR2gZNGnMcbsPaGhIgIhHOxTR2Df0ccwTmwZdYhRb IzXayvTw0RhZzPPB/RQIX9J6qwZYIf7Z35aOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=4OYTehG+Bhg90QqYjzogAsU5vsby1VxPsdvY6UZrUog=; b=GZ5qXM3QurSmMylryRSQoLxIryTxGb0brjRLSbPfGyCEdiCB6ixMkf2mPUmy4L9f67 zNcfzA4vTPD6CuyIuZmzUs58L2OwjcqkG3PltakfOKKfommtJPF+futbJYqRsDRcPqBk GSK/CHe0qxo9t1a3nhfWP7DW3y0S8c1KUCMjCdUfHHnVZyU88ciloOwGDA38z4P55oXe 1IuQDULT8qrWHE5FQXvTBQLA9y7/maG/In8IjksnMJ4S0f7UEubXSUrob9tc/F9inc+K lRPSNhO1Jp3GrR1/lmNKIlnCyECoNqU4SIj44etg2fUwu/t258EvRcyEhj1I2/N5mbzx bGiw== X-Gm-Message-State: AG10YOS0xlMjaRnQ4kCxqtXjODyGz1fc6m8BiYrLKjmYSpOjxRGSalzCeL4OA5Uv+v+QaA== X-Received: by 10.28.21.19 with SMTP id 19mr17021437wmv.43.1455198561395; Thu, 11 Feb 2016 05:49:21 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id r10sm7643692wjz.24.2016.02.11.05.49.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 05:49:19 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] null_blk: oops when initializing without lightnvm Date: Thu, 11 Feb 2016 14:49:13 +0100 Message-Id: <1455198553-24359-1-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the LightNVM subsystem is not compiled into the kernel, and the null_blk device driver requests lightnvm to be initialized. The call to nvm_register fails and the null_add_dev function cleans up the initialization. However, at this point the null block device has already been added to the nullb_list and thus a second cleanup will occur when the function has returned, that leads to a double call to blk_cleanup_queue. Signed-off-by: Matias Bjørling --- drivers/block/null_blk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index ae05d31..64a7b59 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -707,9 +707,7 @@ static int null_add_dev(void) queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q); queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q); - mutex_lock(&lock); - list_add_tail(&nullb->list, &nullb_list); nullb->index = nullb_indexes++; mutex_unlock(&lock); @@ -743,6 +741,10 @@ static int null_add_dev(void) strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN); add_disk(disk); + + mutex_lock(&lock); + list_add_tail(&nullb->list, &nullb_list); + mutex_unlock(&lock); done: return 0;