Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751295AbeADXeu (ORCPT + 1 other); Thu, 4 Jan 2018 18:34:50 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:47021 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbeADXes (ORCPT ); Thu, 4 Jan 2018 18:34:48 -0500 X-Google-Smtp-Source: ACJfBotAynSfjDL7vkER1ra6mxzQspsk24DGNgrmkvIpw/EO3nte95oGGnZypXZjNysnUVeFcww8yg== From: Xiongwei Song To: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com, maco@android.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: android: check the return value of register_shrinker Date: Fri, 5 Jan 2018 07:34:36 +0800 Message-Id: <20180104233436.4703-1-sxwjean@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: register_shrinker call is made in ashmem_init, it may return error code, so we need to check it. Signed-off-by: Xiongwei Song --- v1->v2: remove unlikely() --- drivers/staging/android/ashmem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 4e8947923904..5d7aa55efb22 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -854,12 +854,18 @@ static int __init ashmem_init(void) goto out_free2; } - register_shrinker(&ashmem_shrinker); + ret = register_shrinker(&ashmem_shrinker); + if (ret) { + pr_err("failed to register shrinker!\n"); + goto out_demisc; + } pr_info("initialized\n"); return 0; +out_demisc: + misc_deregister(&ashmem_misc); out_free2: kmem_cache_destroy(ashmem_range_cachep); out_free1: -- 2.15.1