Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3850505imw; Thu, 7 Jul 2022 08:31:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ueXpN4TlRX3D1DRJQ7b0v8roAXQNuIrpOm2u9mir9AfxgqUQnm7lq8AzVmUAJWtOmii6PJ X-Received: by 2002:a17:907:7ba8:b0:72b:1491:c73c with SMTP id ne40-20020a1709077ba800b0072b1491c73cmr2065996ejc.415.1657207890312; Thu, 07 Jul 2022 08:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657207890; cv=none; d=google.com; s=arc-20160816; b=ojkcU501Q13j3aN0SH3HeIJyADT8mS6kgnzd25NtrDO4E7B+cKdeATJ6ttMoUhcwZ/ owJAH22uK5rUBjEcSu0knAFV8niygFDD7/t3eAjeVnCV68iZYmdDHHWTeBMS45Uvz618 gKkgZZzVbv8usbDgkOnJR21kJ+vcbI6cfsoDflS92U1qrq9p7DTKtZmsbVZRNvo/AaIo dDrFkyLS1VTa0Ukg3nsT2d7Q3u+1O27wZkYhqUU4N6e78vR78uIEZCOM8ICayu9oLKaQ XBRcQ+C1mHY0YIo03h64OgBQ6c+Q4WloTPUpmeHTwMTj/xXGCxIzNJpITfzN/jH5Lhix dFEA== 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:from; bh=tKPMVqNrIe5Ig4B8d2M7yr+qfIp4tYp/ydglpOhlukI=; b=N5iPAwkj8q2dtm1vOUdd3xC6igU47c7nyrVv9/SaqChRDi1t7vbi9XasBJhM2eFeei yPZcn5F3r3+gUsnfpiVGkkThEfaCG+d7u2SzN5ftozSKLDIbZJRI3f/7RnbQPmATYuEr yI1nsFmOTViReBO49+2hGfKEhqCDfsZHbs/pY/mekPaRugtBQbhrdvr9rf0BKGdQVs2B 9vf3pWnQptu1pObXkmrsxhFL69ELU1TRuydEPNT3bXKpWhYsG76zTI+R6//9D1pgUjwR aD2Q8SOGhR6yonRGDSYfxzT2Swj+huisU90YwcjEAfbz1kPAexxHp9OGloBflgmdl5yZ EGUA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o1-20020a056402438100b0043a78c17234si6874837edc.342.2022.07.07.08.30.59; Thu, 07 Jul 2022 08:31:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235240AbiGGO07 (ORCPT + 99 others); Thu, 7 Jul 2022 10:26:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232153AbiGGO06 (ORCPT ); Thu, 7 Jul 2022 10:26:58 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3254127CEC for ; Thu, 7 Jul 2022 07:26:57 -0700 (PDT) Received: from andrey-lpc.intra.ispras.ru (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPS id 8FF2D40D4004; Thu, 7 Jul 2022 14:26:53 +0000 (UTC) From: Andrey Strachuk To: "Matthew Wilcox (Oracle)" Cc: Andrey Strachuk , linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] efs: removed useless conditional checks in function Date: Thu, 7 Jul 2022 17:26:52 +0300 Message-Id: <20220707142652.14447-1-strochuk@ispras.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 At lines 300 and 305, variable "bh" is compared with NULL. ----------------------------------------------------------- 293 exts = (efs_extent *) bh->b_data; 294 295 extent_copy(&(exts[ioffset]), &ext); 296 297 if (ext.cooked.ex_magic != 0) { 298 pr_err("extent %d has bad magic number in block %d\n", 299 cur, iblock); 300 if (bh) brelse(bh); 301 return 0; 302 } 303 304 if ((result = efs_extent_check(&ext, block, sb))) { 305 if (bh) brelse(bh); 306 in->lastextent = cur; 307 return result; 308 } ----------------------------------------------------------- However, it cannot be NULL because kernel crashes at line 293 otherwise. The patch removes useless comparisons. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Andrey Strachuk Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") --- fs/efs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/efs/inode.c b/fs/efs/inode.c index 3ba94bb005a6..a88a0600cdfb 100644 --- a/fs/efs/inode.c +++ b/fs/efs/inode.c @@ -297,12 +297,12 @@ efs_block_t efs_map_block(struct inode *inode, efs_block_t block) { if (ext.cooked.ex_magic != 0) { pr_err("extent %d has bad magic number in block %d\n", cur, iblock); - if (bh) brelse(bh); + brelse(bh); return 0; } if ((result = efs_extent_check(&ext, block, sb))) { - if (bh) brelse(bh); + brelse(bh); in->lastextent = cur; return result; } -- 2.25.1