From patchwork Tue Dec 6 09:32:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 30172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2725106wrr; Tue, 6 Dec 2022 01:46:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf66h0KhJE99dMENhY0fC8z/Bh6tc6KcFgGp5Upgt1ErQ3M6cg7gtfL2SGO2OSSqogya8opg X-Received: by 2002:a17:903:32d0:b0:189:8e05:e2da with SMTP id i16-20020a17090332d000b001898e05e2damr42821151plr.116.1670319973800; Tue, 06 Dec 2022 01:46:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670319973; cv=none; d=google.com; s=arc-20160816; b=QhjAOPCUFOJbknsM7mLPISIs8uSaVxDQOehfwQqTSNYC5VAiHf/jw0+/urhcKx8oWH qmiBQxqPvy6rtWIXpXi62Dk59hzvMCcVkeheD/UhDkVqNU/XtQv3mszQQ/+NNp40voZ7 QrKSh36HhwweJMBnQh6AipJdQV75iBa42nFgxXV6kXu6LvLp+XZfG91GItlqVyC76Md+ eFDYamSe5dTgRy/LTwz32yx9WCJFL/tOe9K5Ze/WLbwZA699sJIhxb5jX0/fvGFGlTbN 8DSsZJqluiAEtbmWXQ1PrucuVbdc16Dh+QqJgrwV2Sfb+PzOxRnCbq09nwQLrOWkwPAa R97g== 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 :message-id:date:subject:cc:to:dkim-signature:from; bh=oCm3OMZIxqZDVn064joCmMPgJl8SxdgvibLxjtPgDRU=; b=e0rGc8mD6WtTb8dM/2re5ECl7lGyKSSogM+IDY5rBYxHd06c6QqKZ9G8Mt2XqqR5Su mWAApJTx0FqVqvkZlzD/UU3yo+Sxny9CHmnYDIoHSbaBb9/MCAQbAGc8NOgENyE3tZkU /GG0qV/qvdH+e4M9HInzTGm7d1UzQVEigCoitTFecZWUNnrhJVwnY4aoL3PyVABIL4uj soNwAANwT+2c1cfz29qYDAswtz9Pd2GMCQJSJNo78f2EWCCTmoGbQtYTIUsHFTmMJU2p 0bmy/9hE9IRuQIt3skCosvme6D3//0YDWQUQfy4kxIzqBQyLDXVcbY7yAiTHOrLrcot8 DY+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=DS94TmjN; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a63c151000000b00477a10a91dcsi16830910pgi.695.2022.12.06.01.45.59; Tue, 06 Dec 2022 01:46:13 -0800 (PST) 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=@swemel.ru header.s=mail header.b=DS94TmjN; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233909AbiLFJcX (ORCPT + 99 others); Tue, 6 Dec 2022 04:32:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232554AbiLFJcS (ORCPT ); Tue, 6 Dec 2022 04:32:18 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C96A1D0CB; Tue, 6 Dec 2022 01:32:17 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1670319133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oCm3OMZIxqZDVn064joCmMPgJl8SxdgvibLxjtPgDRU=; b=DS94TmjNMU2BFTBVqyYOH3lkLVGzP9hJzb/sgawSRJT87V5TWsNIyLhkcEwO2xcWM00wFW Ni39B6aoijZqlmnyFgSVoCDx5pz+hcx2CMvZffTDu1VLVZzN0e03VpDcRXAZBlKZiFYRXF p47FCC3wBoDb7UMvfrNqsWiZobD0qjA= To: David Sterba Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] file: Added pointer check Date: Tue, 6 Dec 2022 12:32:13 +0300 Message-Id: <20221206093213.29050-1-arefev@swemel.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751457436423748078?= X-GMAIL-MSGID: =?utf-8?q?1751457436423748078?= Return value of a function 'affs_bread' is dereferenced at file.c:970 without checking for null, but it is usually checked for this function. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Denis Arefev --- fs/affs/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/affs/file.c b/fs/affs/file.c index d91b0133d95d..4566fa767f65 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -963,6 +963,8 @@ affs_truncate(struct inode *inode) while (ext_key) { ext_bh = affs_bread(sb, ext_key); + if (!ext_bh) + break; size = AFFS_SB(sb)->s_hashsize; if (size > blkcnt - blk) size = blkcnt - blk;