Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2490166rwb; Mon, 3 Oct 2022 01:11:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rsckg6mdz4Ga42JaXsucwAuRwMZ3m2haLJbtn9bKzII6a0ybktzLXsVenZY7me33b1IFN X-Received: by 2002:a65:6908:0:b0:44e:1349:1108 with SMTP id s8-20020a656908000000b0044e13491108mr3860017pgq.180.1664784693727; Mon, 03 Oct 2022 01:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664784693; cv=none; d=google.com; s=arc-20160816; b=IwC9gpUe1drBSiIYojLYmdWBEYcjPEtPMjYIxXwUob/vYnMakDNXJi3YYRH4KRBA4p WoP3FI3vT5Lj0prUFduhxJI2ZtstNcvZDiZo6Aj6zx5pcyMwWqtfBt0WF135tANcCtq/ chRZEWI6TN38UXOajAEUzRHdrtFB7+4j3jA9mm1Rvvx6rixzMh9uerMgMJJ21tzjTkHV dRMyPhMz6nyIJgf85S3IFXaE/Z16tx16orjLn0B5KYvezMblgtb0fidNv0DBzoLpC8Ie OiLLb7uOyvdSLLHYf0y5kRybNmQmSK4nHOEGP/nEjmRnA8RjQm1RvOf2f2zffoHmiL4j xLfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FqSYGXtiLSxnodFf1MPHL0ayIildjb+oAzU7oxdhlQg=; b=Bc/9CWQlG+tfRaCyhO6RdFHovMZ4C7LtBH3jinnGCa9jnzKg50r68WyLSRjRaWvdbW 1EVTV9XNr/yA909kAWn7uDuF28lbKeL88R/7bgaA7BAq+N2FW0cIZUd+T+1TXSnE7QjT 7rxna8kJrhN6CYLFB4GNbJ10eTNlZAVS6CMqBOj1xUAy0YG/nXmoWQfsBplpvO+n036I 7ouqVNm5zwOr2DXYi5e9HxnSOsrU1TQoNk9NJE0v7vzH8yCEjmD/9cvLbBD6oVyPqE2U jeosteKXQhu1OkEU2DJqWvbdQX362LhRqzXtVa5OxnggzVjAZkML9oLHhoZ1d8uFHTvH FExQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yPcOsksc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a63490c000000b004350783ee63si9642603pga.237.2022.10.03.01.11.21; Mon, 03 Oct 2022 01:11:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yPcOsksc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbiJCHal (ORCPT + 99 others); Mon, 3 Oct 2022 03:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbiJCH3L (ORCPT ); Mon, 3 Oct 2022 03:29:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BC7B7C9; Mon, 3 Oct 2022 00:20:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A7602B80E72; Mon, 3 Oct 2022 07:19:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25580C433D7; Mon, 3 Oct 2022 07:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781545; bh=lpaqM68iF2A+dnBUkjIFdA/gEKCDcJqoCeNWy5/CwWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yPcOsksckQOzxq7xW473yun18FxjQnN34R48fpoQFyTZdJ7h5+jHvTzJ+wNiLQI56 mXg2pltLnyyKZOBtDx3++6G+Z3Y1N0uS+03h4gpAHmYD3EFSNHshG9DEK1lx/E/eN8 eSAl8wTfZ4Aa81OYNEEh6QLNILdt1JIPiNqn9bSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Binyi Han , Andrew Morton , Mike Rapoport , Ammar Faizi , Hagen Paul Pfeifer , James Bottomley , Andrew Morton Subject: [PATCH 5.15 31/83] mm: fix dereferencing possible ERR_PTR Date: Mon, 3 Oct 2022 09:10:56 +0200 Message-Id: <20221003070722.780081220@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Binyi Han commit 4eb5bbde3ccb710d3b85bfb13466612e56393369 upstream. Smatch checker complains that 'secretmem_mnt' dereferencing possible ERR_PTR(). Let the function return if 'secretmem_mnt' is ERR_PTR, to avoid deferencing it. Link: https://lkml.kernel.org/r/20220904074647.GA64291@cloud-MacBookPro Fixes: 1507f51255c9f ("mm: introduce memfd_secret system call to create "secret" memory areas") Signed-off-by: Binyi Han Reviewed-by: Andrew Morton Cc: Mike Rapoport Cc: Ammar Faizi Cc: Hagen Paul Pfeifer Cc: James Bottomley Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/secretmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/secretmem.c +++ b/mm/secretmem.c @@ -283,7 +283,7 @@ static int secretmem_init(void) secretmem_mnt = kern_mount(&secretmem_fs); if (IS_ERR(secretmem_mnt)) - ret = PTR_ERR(secretmem_mnt); + return PTR_ERR(secretmem_mnt); /* prevent secretmem mappings from ever getting PROT_EXEC */ secretmem_mnt->mnt_flags |= MNT_NOEXEC;