Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A6C5C433EF for ; Tue, 7 Jun 2022 08:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237612AbiFGIyw (ORCPT ); Tue, 7 Jun 2022 04:54:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238798AbiFGIye (ORCPT ); Tue, 7 Jun 2022 04:54:34 -0400 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 31680E5298 for ; Tue, 7 Jun 2022 01:54:33 -0700 (PDT) IronPort-Data: =?us-ascii?q?A9a23=3Ahu7RuK5kbGoq26c89/4r+QxRtATFchMFZxGqfqr?= =?us-ascii?q?LsXjdYENS0jxTxmZLDWHTb/jeYTbxKt12Pd619U4DvJ+BzINmTVA5pCpnJ55og?= =?us-ascii?q?ZCbXIzGdC8cHM8zwvXrFRsht4NHAjX5BJhcokT0+1H9YtANkVEmjfvSHuCkUba?= =?us-ascii?q?dUsxMbVQMpBkJ2EsLd9ER0tYAbeiRW2thiPuqyyHtEAbNNw1cbgr435m+RCZH5?= =?us-ascii?q?5wejt+3UmsWPpintHeG/5Uc4Ql2yauZdxMUSaEMdgK2qnqq8V23wo/Z109F5tK?= =?us-ascii?q?NmbC9fFAIQ6LJIE6FjX8+t6qK20AE/3JtlP1gcqd0hUR/0l1lm/hr1dxLro32R?= =?us-ascii?q?wEyIoXCheYcTwJFVSp5OMWq/ZeeeyTg7JLIkhSun3zEhq8G4FsNFYER/KB8CHt?= =?us-ascii?q?W+PoEJSolaQqKjOa7hrm8T4FEgsUlMdmuMpgTt29tyRnHAvs8B5POWaPH4Zlfx?= =?us-ascii?q?jhYuyzkNZ4yfOJAMXw2MkuGOEYJZz8q5FsFtL/ArhHCn/dw8jp5fZYK3lU=3D?= IronPort-HdrOrdr: =?us-ascii?q?A9a23=3A7dv+MaCfrBUjrUblHemQ55DYdb4zR+YMi2TD?= =?us-ascii?q?tnoBLSC9F/b0qynAppomPGDP4gr5NEtApTniAtjkfZq/z+8X3WB5B97LMzUO01?= =?us-ascii?q?HYTr2Kg7GD/xTQXwX69sN4kZxrarVCDrTLZmRSvILX5xaZHr8brOW6zA=3D=3D?= X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="124756351" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Jun 2022 16:54:32 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 8725B4D17162; Tue, 7 Jun 2022 16:54:29 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 7 Jun 2022 16:54:29 +0800 Received: from [192.168.22.78] (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Tue, 7 Jun 2022 16:54:29 +0800 Message-ID: <8d640912-d253-bcbb-fcd1-cff645fb09a2@fujitsu.com> Date: Tue, 7 Jun 2022 16:54:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [bug report] fsdax: output address in dax_iomap_pfn() and rename it To: Dan Carpenter CC: References: From: Shiyang Ruan In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-yoursite-MailScanner-ID: 8725B4D17162.ADD2E X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 在 2022/6/7 15:59, Dan Carpenter 写道: > Hello Shiyang Ruan, > > The patch 1447ac26a964: "fsdax: output address in dax_iomap_pfn() and > rename it" from Jun 3, 2022, leads to the following Smatch static > checker warning: > > fs/dax.c:1085 dax_iomap_direct_access() > error: uninitialized symbol 'rc'. > > fs/dax.c > 1052 static int dax_iomap_direct_access(const struct iomap *iomap, loff_t pos, > 1053 size_t size, void **kaddr, pfn_t *pfnp) > 1054 { > 1055 pgoff_t pgoff = dax_iomap_pgoff(iomap, pos); > 1056 int id, rc; > 1057 long length; > 1058 > 1059 id = dax_read_lock(); > 1060 length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), > 1061 DAX_ACCESS, kaddr, pfnp); > 1062 if (length < 0) { > 1063 rc = length; > 1064 goto out; > 1065 } > 1066 if (!pfnp) > 1067 goto out_check_addr; > > Is this an error path? > > 1068 rc = -EINVAL; > 1069 if (PFN_PHYS(length) < size) > 1070 goto out; > 1071 if (pfn_t_to_pfn(*pfnp) & (PHYS_PFN(size)-1)) > 1072 goto out; > 1073 /* For larger pages we need devmap */ > 1074 if (length > 1 && !pfn_t_devmap(*pfnp)) > 1075 goto out; > 1076 rc = 0; > 1077 > 1078 out_check_addr: > 1079 if (!kaddr) > 1080 goto out; > > How is it supposed to be handled if both "pfnp" and "kaddr" are NULL? > > Smatch says that "kaddr" can never be NULL so this code is just future > proofing but I didn't look at it carefully. Yes, we always pass the @kaddr in all caller, it won't be NULL now. And even @kaddr and @pfnp are both NULL, it won't cause any error. So, I think the rc should be initialized to 0 : { pgoff_t pgoff = dax_iomap_pgoff(iomap, pos); - int id, rc; + int id, rc = 0; long length; Do I need to fix this and resend a patch to the list? Or you could help me fix this? -- Thanks, Ruan. > > 1081 if (!*kaddr) > 1082 rc = -EFAULT; > 1083 out: > 1084 dax_read_unlock(id); > --> 1085 return rc; > 1086 } > > regards, > dan carpenter