Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2531273rdb; Fri, 18 Aug 2023 03:19:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhKp12c7vZtUW90kT0no9ebBuGbU84dzf9GDAKurMK22Vj96n7bUiGraljiZ9RDPo6WY4h X-Received: by 2002:a05:6a20:1007:b0:140:d536:d435 with SMTP id gs7-20020a056a20100700b00140d536d435mr2485511pzc.38.1692353950914; Fri, 18 Aug 2023 03:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692353950; cv=none; d=google.com; s=arc-20160816; b=G+YvW/I/c4Sgb5dAAdw4EvnFmZnb+Bh6N15JbgmXfKj8Xv4uRiz+xchBgdjE6PyPyW zAPEmYPv9AtWrDtsy4gs3jXn7bZupEiU/J3+roNRbufQjdp0jnR5gbZWRLIX7i7FeOzk Z9J77nm7zlYA0awCkwBTR0USoSih/rqa+WPqNm9Nc8d8Q07gQ5Y3TmDGik+Sf+4tS1lq EJpBQSWcCsfZ0zO0+UwqmTV7gD5MO1czdeidBOS37v1zrHeOAUVRiB2Ctm1ehFLu2XUo U3f8Jrnwr1zJ3sNquXEV4NLTcHc+zczS4rEdTOyC+nYQ9Nsm3kYQZwegOE7O3kkI2J3Z lPTA== 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=+FLcVG28Je7JmmUkJheOQeARS2Hg/LwLTnGtOWrlKBg=; fh=rPuKRJO9kH1EnVBoStHBrF5oiMAAOZ7RZoatc6FNrnw=; b=haBy63hp+y6P+NsX/R9JEWKFxYrrQbD5N4xAZB+B+TSYtBjZLjxT1nc9d5V1TysUPt dLv3nSd0D8av3NBTRBm6tY4PfRjb7PmprDHXZ108IuRDkO0xCvkJ65Tq77AWH21hUNcm GsBsrqdyosZhPsn17N09tBS2sVsP4WV6U90uVNFJ16N4YHbQkJlPpRSd5ya0ZRB251i8 wwCf4+GKPhfZZr7ZxWedJpfT03DrLwz3VtdcfAQvnMlLW3TMHgQSY1ogdNWZbFUdZSfs eOkUfVlp0qjWLWGqb0gDMS/7XCWDOOQgzjHTIDAkWQEPPcHOtKz1rv9DhQQ90bXhDCbq ofZw== 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=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a634c10000000b0056401aef836si1145499pga.822.2023.08.18.03.18.53; Fri, 18 Aug 2023 03:19:10 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359023AbjHRJUw (ORCPT + 99 others); Fri, 18 Aug 2023 05:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359080AbjHRJUh (ORCPT ); Fri, 18 Aug 2023 05:20:37 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6C23AA6; Fri, 18 Aug 2023 02:20:33 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=mengferry@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0Vq26Rhg_1692350423; Received: from j66c13357.sqa.eu95.tbsite.net(mailfrom:mengferry@linux.alibaba.com fp:SMTPD_---0Vq26Rhg_1692350423) by smtp.aliyun-inc.com; Fri, 18 Aug 2023 17:20:30 +0800 From: Ferry Meng To: Ryusuke Konishi , linux-nilfs@vger.kernel.org Cc: LKML , Ferry Meng Subject: [PATCH] nilfs2: fix dereferencing freed memory Date: Fri, 18 Aug 2023 17:20:22 +0800 Message-Id: <20230818092022.111054-1-mengferry@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 Fix smatch warning: fs/nilfs2/gcinode.c:103 nilfs_gccache_submit_read_data() error: dereferencing freed memory 'bh' Signed-off-by: Ferry Meng diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c index 48fe71d309cb..6319e825f317 100644 --- a/fs/nilfs2/gcinode.c +++ b/fs/nilfs2/gcinode.c @@ -73,10 +73,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, struct the_nilfs *nilfs = inode->i_sb->s_fs_info; err = nilfs_dat_translate(nilfs->ns_dat, vbn, &pbn); - if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */ - brelse(bh); + if (unlikely(err)) /* -EIO, -ENOMEM, -ENOENT */ goto failed; - } } lock_buffer(bh); @@ -102,6 +100,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, failed: unlock_page(bh->b_page); put_page(bh->b_page); + if (err) + brelse(bh); return err; } -- 2.19.1.6.gb485710b