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 287E8C433DF for ; Wed, 12 Aug 2020 01:34:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E23702076C for ; Wed, 12 Aug 2020 01:34:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="lEUu8AIc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E23702076C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 87DB58D004C; Tue, 11 Aug 2020 21:34:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82F5E8D0001; Tue, 11 Aug 2020 21:34:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F58B8D004C; Tue, 11 Aug 2020 21:34:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 5A3E48D0001 for ; Tue, 11 Aug 2020 21:34:49 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 238ED181AEF10 for ; Wed, 12 Aug 2020 01:34:49 +0000 (UTC) X-FDA: 77140197498.29.fowl86_461603f26fe7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id F390718086E33 for ; Wed, 12 Aug 2020 01:34:48 +0000 (UTC) X-HE-Tag: fowl86_461603f26fe7 X-Filterd-Recvd-Size: 3623 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Aug 2020 01:34:48 +0000 (UTC) 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 X-Rspamd-Queue-Id: F390718086E33 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 || _