Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933204AbbHZMbw (ORCPT ); Wed, 26 Aug 2015 08:31:52 -0400 Received: from h1446028.stratoserver.net ([85.214.92.142]:41035 "EHLO mail.ahsoftware.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932614AbbHZMbt (ORCPT ); Wed, 26 Aug 2015 08:31:49 -0400 From: Alexander Holler To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Greg KH , Russel King , Andrew Morton , Grant Likely , Tomeu Vizoso , Alexander Holler , David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org Subject: [PATCH 15/16] mtd: mtdcore: fix initcall level Date: Wed, 26 Aug 2015 14:28:27 +0200 Message-Id: <1440592108-3740-16-git-send-email-holler@ahsoftware.de> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1440592108-3740-1-git-send-email-holler@ahsoftware.de> References: <1440592108-3740-1-git-send-email-holler@ahsoftware.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1342 Lines: 39 The mtd-core has to be initialized before other dependent mtd-drivers, otherwise a crash might occur. Currently mtd_init() is called in the initcall-level device, which is the same level where most mtd-drivers will end up. By luck this seemed to have been called most of the time before other mtd-drivers without having been explicitly enforced. But if mtd_init() is not called before a dependent driver, a null-pointer exception might occur (e.g. because the mtd device class isn't registered). To fix this, mtd-init() is moved to the initcall-level fs (right before the standard initcall level device). Signed-off-by: Alexander Holler --- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 8bbbb75..fa8e6452 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -1303,7 +1303,7 @@ static void __exit cleanup_mtd(void) bdi_destroy(&mtd_bdi); } -module_init(init_mtd); +fs_initcall_sync(init_mtd); module_exit(cleanup_mtd); MODULE_LICENSE("GPL"); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/