Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001AbbERIoA (ORCPT ); Mon, 18 May 2015 04:44:00 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:10377 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbbERInw (ORCPT ); Mon, 18 May 2015 04:43:52 -0400 X-AuditID: cbfee61a-f79516d000006302-b8-5559a6466a86 From: Chao Yu To: dedekind1@gmail.com, adrian.hunter@intel.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ubifs: fix to check error code of register_shrinker Date: Mon, 18 May 2015 16:43:02 +0800 Message-id: <003001d09146$c124b150$436e13f0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdCRRachzwQrpiTmTzuGbOi72VGMsQ== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t9jQV23ZZGhBku/iVucfLKGzeJW92tG i8u75rBZ7G5axu7A4rFz1l12j8V7XjJ5bF5S7/F5k1wASxSXTUpqTmZZapG+XQJXxubp/xkL rrJXLNn7kqmBcQ1bFyMnh4SAicSZTVOhbDGJC/fWA9lcHEIC0xkldr2cCuW8YpTomfKREaSK TUBFYnnHfyYQW0TAQOLE9iVg3cwC9hKnFm9lB7GFBVwkvrS+ZgWxWQRUJX5uPcvcxcjBwStg KdE+IQ0kzCsgKPFj8j0WiFYtifU7jzNB2PISm9e8ZYY4SEFix9nXjBCr9CQOX9vKClEjLrHx yC2WCYwCs5CMmoVk1Cwko2YhaVnAyLKKUTS1ILmgOCk911CvODG3uDQvXS85P3cTIzikn0nt YFzZYHGIUYCDUYmH1+JNRKgQa2JZcWXuIUYJDmYlEd5fzZGhQrwpiZVVqUX58UWlOanFhxil OViUxHlP5vuECgmkJ5akZqemFqQWwWSZODilGhjrzngqv8hz/pO/+ESFsIvPlynTp2i1xj6d VbphocBR6xOnTL67cHSJH1Sp3figa2PO1Crv69d2MJfFfKnhVrSruSg+MZlTbrvAtH3XWiRU g+++ZlOrlNsgeGxdIOvyzvnJdY+eVbY6KU6JDDc6PF9q1UKbRXf2NbIYflsqXMljXO1/aa2d Z5oSS3FGoqEWc1FxIgBBUwa2ZQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1190 Lines: 41 register_shrinker() in ubifs_init() can fail due to fail to call kzalloc. This patch fixes to check the return value of register_shrinker, otherwise our shrinker may be unregistered after ubifs initialized successfully. Signed-off-by: Chao Yu --- fs/ubifs/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 75e6f04..fa83d1b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2245,7 +2245,9 @@ static int __init ubifs_init(void) if (!ubifs_inode_slab) return -ENOMEM; - register_shrinker(&ubifs_shrinker_info); + err = register_shrinker(&ubifs_shrinker_info); + if (err) + goto out_slab; err = ubifs_compressors_init(); if (err) @@ -2269,6 +2271,7 @@ out_compr: ubifs_compressors_exit(); out_shrinker: unregister_shrinker(&ubifs_shrinker_info); +out_slab: kmem_cache_destroy(ubifs_inode_slab); return err; } -- 2.3.3 -- 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/