Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4329ybd; Fri, 28 Jun 2019 13:20:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqz03Zjh0N/gWUfU35qLmCcs7R5S0j+s/qqcPfLNCYK8355TsnrExRS9XNroBTVTL76ofJZI X-Received: by 2002:a17:90b:d8b:: with SMTP id bg11mr15409170pjb.30.1561753202561; Fri, 28 Jun 2019 13:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561753202; cv=none; d=google.com; s=arc-20160816; b=E2i89AvuzkJYeQRnN1WAg8eb14oUVdnZRM9P21eYKgeYSSD0RUwq3jpryjJTMCPavt g2kFxQ+qwBLs9fdi8RLNRhRINWgn6MrxsIxtip8yasGu76oHBvejBEFCd3Lcz2U2KAvm v4mxnkfZ+nIbB4C4jkCbFL151zLHFkSr9hH2XToZwjuvT5u171T83PKkVE4YJsk9l8DX IRv3QD+sQjAKRA3oUAes2v+KnEzjiGPsE2qjjdfiwKVzLo1/Tc9UsH6G4bgwXmSpzzMT 59sSwftwQz+UP4gP23G9/rjuJRMPPGEpfjeX9+oseE3siqGBghQ6Eug573lgvCB2Ba2l AWMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:organization:subject:cc:to:from; bh=YtZYW89k3E5nC9y96BQop4FgoS7gpRzxrWS/zrdzYCc=; b=q4TLFBhQ7rD9S6zP/q06Yfk76mYlo+Oy6OfEykbEM0FvyVx7XghB7yvnatCTONVmma AYIEbPAH73XJgyXjYK17M9cnih4/qEMxNYL/v3QgJUsTaLIm0LKe8lvju3pME+BDmQGs ajOFtIFI78ppiT1NioJQyra57qeOkcEDGp7Trq4kzwRluHqosh5pUmP2Aew8Tx6ZzSt/ I3vON9yo9n+d3ITVTHR9bmGJSvp2VvUHVM4aeT/DZUSJBSc97oPYn9L9N3NzP/usW1O8 tGsKTImzxoOidc3YM66JBXuiLqaFojKnY4JT2xQccLxFADHwv2PW2L575oA5aVXB7mcD S4bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g195si3348776pfb.158.2019.06.28.13.19.39; Fri, 28 Jun 2019 13:20:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727079AbfF1UTh (ORCPT + 99 others); Fri, 28 Jun 2019 16:19:37 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58102 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbfF1UTh (ORCPT ); Fri, 28 Jun 2019 16:19:37 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id D8D97284D58 From: Gabriel Krisman Bertazi To: Dan Carpenter Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, kernel@collabora.com Subject: [PATCH] ext4: Fix coverity warning on error path of filename setup Organization: Collabora References: <20190624122906.GA30836@mwanda> Date: Fri, 28 Jun 2019 16:19:32 -0400 In-Reply-To: <20190624122906.GA30836@mwanda> (Dan Carpenter's message of "Mon, 24 Jun 2019 15:29:06 +0300") Message-ID: <85r27dlay3.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Dan Carpenter writes: > Hello Gabriel Krisman Bertazi, > > The patch 3ae72562ad91: "ext4: optimize case-insensitive lookups" > from Jun 19, 2019, leads to the following static checker warning: Hi, The patch below should fix this issue. -- >8 -- Subject: [PATCH] ext4: Fix coverity warning on error path of filename setup Fix the following coverity warning reported by Dan Carpenter: fs/ext4/namei.c:1311 ext4_fname_setup_ci_filename() warn: 'cf_name->len' unsigned <= 0 Fixes: 3ae72562ad91 ("ext4: optimize case-insensitive lookups") Signed-off-by: Gabriel Krisman Bertazi Reported-by: Dan Carpenter --- fs/ext4/namei.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4909ced4e672..898295286676 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1296,6 +1296,8 @@ int ext4_ci_compare(const struct inode *parent, const struct qstr *name, void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, struct fscrypt_str *cf_name) { + int len; + if (!IS_CASEFOLDED(dir)) { cf_name->name = NULL; return; @@ -1305,13 +1307,16 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, if (!cf_name->name) return; - cf_name->len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, - iname, cf_name->name, - EXT4_NAME_LEN); - if (cf_name->len <= 0) { + len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, + iname, cf_name->name, + EXT4_NAME_LEN); + if (len <= 0) { kfree(cf_name->name); cf_name->name = NULL; + return; } + cf_name->len = (unsigned) len; + } #endif -- 2.20.1