Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1238150pxa; Thu, 20 Aug 2020 06:27:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWIM//Rk2rh+HXSoAS4INETg/ChvnHUhSFPN1XGXRLAhYSJgh2ITmq78ojMZCYmZcXWeoe X-Received: by 2002:a17:906:3e06:: with SMTP id k6mr1462805eji.37.1597930045711; Thu, 20 Aug 2020 06:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597930045; cv=none; d=google.com; s=arc-20160816; b=SD5o8M7ASGjqu0fm30scNUmvv1xB+EhybY4P2pb4gGjVDTtScmpNzmFHyH9Uk2zs3l sgi8nqyR/gM1eCcrkqEQpvHNU70mp4CC1C5JJgKbBQr4CnaCMNcnFUiGOpdxhZ6HwjB1 WXzZrUpTsZ355VKI8FKtwgcIkiXDE5zFzvQE1oDfupTrhYMvFsp9NdNOFwGdVy6D7D4T u6IpI6GqSNSRS0NI/ELf/FWDtvkDpEfg0q0fTWIDgpRt/kXpgR2PBaOTQL0trYo8IvLV U83+dJkSs5eME5f46J17yCVtfAvCEzpZcMEJAO13zkhtoXiqM//D0HdmGwyQalMnIzfe 0AMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kkPK6gZf3Gdb+oj5FhdkezIIC0p4ZaOal8tuteHOTb0=; b=VQ2R07+oILCz4icahvN6djpf8u7iMRsaM8lKgn0MD4TlVt8SH82On0pW7C55GdCOGN smWawxaThHk2G0rdONURzG5c2Ujhm7BWCfE+V8apOOodsZeMypoA4kiKlnSBEa2hAmCy 2C4URfUpVHx5jVoDhBhHB2ObsxXxqKkGb5AqHZLCEtwA/LeqAkzQ3O2jyZooAfvs2E2i yEgPZuN9tu5E5qy+qHjhib8/A7X/9ORAkABLX9CG/kujajYeUQ5lkszJqfjGfoymxjJP 72u6RCWP9zASMf9cDXJpvEzTp1548mSispuyLoWMHA671KX5s9H2fX5vQRdFVlDZnH5E 4yjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L+1kDLtX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si1220835eja.41.2020.08.20.06.27.01; Thu, 20 Aug 2020 06:27:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L+1kDLtX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730425AbgHTNYW (ORCPT + 99 others); Thu, 20 Aug 2020 09:24:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:45704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728398AbgHTJdY (ORCPT ); Thu, 20 Aug 2020 05:33:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A898922B43; Thu, 20 Aug 2020 09:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915987; bh=ayR58E/HkqMTNKquLhSI45UEGPZWQDPCo6KAuDomwQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+1kDLtXpYJYGDKK+WLCmROCP1GCxfta20+l+Y8QzESEiLfaPisXoRy2rTq94DGll Ryg3ryZF33+PNx6QHzIaQPA7SiPygw7ezdJxpJgeugzz8ytdQJhY7OZNSqJY51G2Ct Zv+4GRJTewChjKmGAy3mUj48Df3u2lccnty+WpH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tiezhu Yang , Andrew Morton , Guenter Roeck , Konstantin Khlebnikov , Kees Cook , Linus Torvalds , Sasha Levin Subject: [PATCH 5.8 205/232] lib/test_lockup.c: fix return value of test_lockup_init() Date: Thu, 20 Aug 2020 11:20:56 +0200 Message-Id: <20200820091622.740690835@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tiezhu Yang [ Upstream commit 3adf3bae0d612357da516d39e1584f1547eb6e86 ] 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 Fixes: aecd42df6d39 ("lib/test_lockup.c: add parameters for locking generic vfs locks") Signed-off-by: Tiezhu Yang Signed-off-by: Andrew Morton Reviewed-by: Guenter Roeck Cc: Konstantin Khlebnikov Cc: Kees Cook Link: http://lkml.kernel.org/r/1595555407-29875-2-git-send-email-yangtiezhu@loongson.cn Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- lib/test_lockup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_lockup.c b/lib/test_lockup.c index bd7c7ff39f6be..e7202763a1688 100644 --- a/lib/test_lockup.c +++ b/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 || -- 2.25.1