From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25A79C433E0 for ; Wed, 12 Aug 2020 01:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06C092076C for ; Wed, 12 Aug 2020 01:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597196089; bh=Zh5K2vd2gCUkv1uqt03kCoU+E1Vs8n3E1+unCg5cEqE=; h=Date:From:To:Subject:In-Reply-To:Reply-To:List-ID:From; b=r5lWA/82bPO5Tjjnw4ra+IeHZ/SxbZvfgScv+YbqfrHX5uC7gKdNtsffUzIKq/UCB AZzneXHZeufNZLtMKhG+I9Hftay3dQopbYJqD3zA/9SUeCba21VWTWyrcn5MowjYte ReMosDMOHJnoliTKPlmLS/9jJkp/Qr0PXy1N8xx0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbgHLBes (ORCPT ); Tue, 11 Aug 2020 21:34:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:35636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726507AbgHLBes (ORCPT ); Tue, 11 Aug 2020 21:34:48 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 94719206B2; Wed, 12 Aug 2020 01:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597196087; bh=Zh5K2vd2gCUkv1uqt03kCoU+E1Vs8n3E1+unCg5cEqE=; h=Date:From:To:Subject:In-Reply-To:From; b=lEUu8AIcGzjoVqJwUhVItTKTq+kyvb/7vCVTQhoQTp64wNmaXL+aMRRSPuMBAiIbz ldSSI7m9P/v7BSIjmeVnBKTLlH73EESnHhKiIlLmf1SaaLRYSMrzr0WbywHGOIFqHy s2Ts8sUBWBmpOI2ohXRwcYTdO2EmF0IhjbFFu508= Date: Tue, 11 Aug 2020 18:34:47 -0700 From: Andrew Morton To: akpm@linux-foundation.org, keescook@chromium.org, khlebnikov@yandex-team.ru, linux-mm@kvack.org, linux@roeck-us.net, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, yangtiezhu@loongson.cn Subject: [patch 086/165] lib/test_lockup.c: fix return value of test_lockup_init() Message-ID: <20200812013447.rXyBf-I7V%akpm@linux-foundation.org> In-Reply-To: <20200811182949.e12ae9a472e3b5e27e16ad6c@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: mm-commits-owner@vger.kernel.org Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org From: Tiezhu Yang Subject: lib/test_lockup.c: fix return value of test_lockup_init() Since filp_open() returns an error pointer, we should use IS_ERR() to check the return value and then return PTR_ERR() if failed to get the actual return value instead of always -EINVAL. E.g. without this patch: [root@localhost loongson]# ls no_such_file ls: cannot access no_such_file: No such file or directory [root@localhost loongson]# modprobe test_lockup file_path=no_such_file lock_sb_umount time_secs=60 state=S modprobe: ERROR: could not insert 'test_lockup': Invalid argument [root@localhost loongson]# dmesg | tail -1 [ 126.100596] test_lockup: cannot find file_path With this patch: [root@localhost loongson]# ls no_such_file ls: cannot access no_such_file: No such file or directory [root@localhost loongson]# modprobe test_lockup file_path=no_such_file lock_sb_umount time_secs=60 state=S modprobe: ERROR: could not insert 'test_lockup': Unknown symbol in module, or unknown parameter (see dmesg) [root@localhost loongson]# dmesg | tail -1 [ 95.134362] test_lockup: failed to open no_such_file: -2 Link: http://lkml.kernel.org/r/1595555407-29875-2-git-send-email-yangtiezhu@loongson.cn Fixes: aecd42df6d39 ("lib/test_lockup.c: add parameters for locking generic vfs locks") Signed-off-by: Tiezhu Yang Reviewed-by: Guenter Roeck Cc: Konstantin Khlebnikov Cc: Kees Cook Signed-off-by: Andrew Morton --- lib/test_lockup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/lib/test_lockup.c~lib-test_lockupc-fix-return-value-of-test_lockup_init +++ a/lib/test_lockup.c @@ -512,8 +512,8 @@ static int __init test_lockup_init(void) if (test_file_path[0]) { test_file = filp_open(test_file_path, O_RDONLY, 0); if (IS_ERR(test_file)) { - pr_err("cannot find file_path\n"); - return -EINVAL; + pr_err("failed to open %s: %ld\n", test_file_path, PTR_ERR(test_file)); + return PTR_ERR(test_file); } test_inode = file_inode(test_file); } else if (test_lock_inode || _