Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp729573imm; Thu, 13 Sep 2018 06:57:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYhvTw6LqgN5dDxr6ECXno+0ZLXC2PWL4w8uXJHQW/yvf/3LevAEUrshcPSudPDnVguy4lo X-Received: by 2002:a17:902:9a83:: with SMTP id w3-v6mr7639896plp.75.1536847027994; Thu, 13 Sep 2018 06:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847027; cv=none; d=google.com; s=arc-20160816; b=Nh8ize8lYaojqdh+ES+HBXqGwVQuBVfjShUh/R1eNRWaXudoI/B+ZF776FbaTDlH4M rEhp3Xj0xJCqGXK/QpKGvjAgKFrQ1L18/dGWLtFNc3Oo8LXdQXMFHMIqHo8A7CRCEWNq Y1b2MSb6jMbg31c4eli9CK7yx5a7k9yNYSeh0ggijhDmRicJv2VgtkSZmoNRgs3WbB/Z rqycEt+EddqN1wr8g0ruSpiCX9WzbiavxdKFCYb76jnIeio773EU6ucIrw6C2LfQM/If xbx36pE0UB9hnpl7iOw454NIq3PG4LYgUwu0k94GLVoi01Gwae/tDg0k4hUVX5lvGLYG IsSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=+fqY5enhXZQIQ1DtlOiiQIZ2D7fT4ztayR3u438Q9Es=; b=Q3A1RUyr7Xdv5vRTtrVVZWa196jFA6U7+PHllzOY+AHI2arzTGQbPQFFhIhZNKOH2z DGdpPFmYvI4NIDe0Wi9lCkEJ76RhJMxb/1su6U3QRudqvA9iQhssqXkr3GfLvU9C5kxW kYBV6A638mfinmE0XDfYWessJUJgSS1Qd0bSvyQ+BhC7En0v3hJmG5jvSDdZytHnoo7f mN8dyihVAB32OyZUzIMqChVowz6F3lghG4AByUrho/2dnMhJfPvEQwtce0BtTQaNtWOl 0ZPTvAMiAFej07+Yd7dJ1FSPnV/blmzK1VsheurzYDQ5n93e5hLpgXkBmExnbUpVbvI0 261g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l63-v6si3950169pgd.598.2018.09.13.06.56.53; Thu, 13 Sep 2018 06:57:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731249AbeIMTFH (ORCPT + 99 others); Thu, 13 Sep 2018 15:05:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33990 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727783AbeIMTFG (ORCPT ); Thu, 13 Sep 2018 15:05:06 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BF13AD19; Thu, 13 Sep 2018 13:55:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "=?UTF-8?q?Ernesto=20A . =20Fern=C3=A1ndez?=" , Anatoly Trosinenko , Viacheslav Dubeyko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.18 039/197] hfs: prevent crash on exit from failed search Date: Thu, 13 Sep 2018 15:29:48 +0200 Message-Id: <20180913131843.116746086@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Ernesto A. Fern?ndez" [ Upstream commit dc2572791d3a41bab94400af2b6bca9d71ccd303 ] hfs_find_exit() expects fd->bnode to be NULL after a search has failed. hfs_brec_insert() may instead set it to an error-valued pointer. Fix this to prevent a crash. Link: http://lkml.kernel.org/r/53d9749a029c41b4016c495fc5838c9dba3afc52.1530294815.git.ernesto.mnd.fernandez@gmail.com Signed-off-by: Ernesto A. Fernández Cc: Anatoly Trosinenko Cc: Viacheslav Dubeyko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/hfs/brec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/hfs/brec.c +++ b/fs/hfs/brec.c @@ -75,9 +75,10 @@ int hfs_brec_insert(struct hfs_find_data if (!fd->bnode) { if (!tree->root) hfs_btree_inc_height(tree); - fd->bnode = hfs_bnode_find(tree, tree->leaf_head); - if (IS_ERR(fd->bnode)) - return PTR_ERR(fd->bnode); + node = hfs_bnode_find(tree, tree->leaf_head); + if (IS_ERR(node)) + return PTR_ERR(node); + fd->bnode = node; fd->record = -1; } new_node = NULL;