From patchwork Sun Jun 25 23:17:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 71649 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A1493858401 for ; Sun, 25 Jun 2023 23:19:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A1493858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687735150; bh=GLUIFJainxaJuSLOPaLTazcTDpF6gsL3kqEWAFrsW6E=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xgGUh9bxd9Op9A38z9wWAGtn2HjqkBo3cb15PSMWzPMDiB3cIvOemsz3A8JY+HQXo cyHmU0CIU8Iy/XjASWzwenq1gmMvwXf5jordiTGmwjEesGhgvOAGpTaezuyXQN/QnU GRBh4URr3m51QMMaQS0RYD66YxHId3G+aAPWxnOQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 5802A3858D35 for ; Sun, 25 Jun 2023 23:18:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5802A3858D35 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4fb73ba3b5dso589424e87.1 for ; Sun, 25 Jun 2023 16:18:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687735082; x=1690327082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GLUIFJainxaJuSLOPaLTazcTDpF6gsL3kqEWAFrsW6E=; b=FzI7cbvRvh9sU0Nf8KvZ/oPgbRtC4gQJkFLcbswCk94yeEVA1rmv8/+Kg5oi0aypHY T0pObyNaSu0SuknFFoVoqXtr3E7EbrlfK2adV/Qy08uLQkh0rTqRN6Vu7RS8f8d15Hmq O/egf4AKzC1xCevks+qXexgksJnZInU5bqBebDio+8/0hOi2tlmMIKQFef1MGJ+FnB8Z 7mKZIKqqyxdluBND2fwhT0gBWD/blOCdV6KFVqHh67rykN+2DACT/4IsD1+ujz40ON7O b7qGKoJ/7Qu2Q7XvrMH0xGBBp4GSAF+ItU7r5v/UUakYtVgmYjW2MXa3GIvhElpA5Ckq TZWQ== X-Gm-Message-State: AC+VfDzvQ1XUAWEuoTlH4e6ajEAdk0QZZI9ujEFl8hA3FcwME0QxFhlZ rtxxYnG8APVzt9NMNC0IHjuZ+wptzrE= X-Google-Smtp-Source: ACHHUZ6zjK81ZgBe2YU8VQK++5l1qZTxYLtco40dKq+FdWUxUfnJpq/CdvCRiZ7uNoOHrke3TqTxeg== X-Received: by 2002:a19:ca4e:0:b0:4f8:8be4:8a82 with SMTP id h14-20020a19ca4e000000b004f88be48a82mr9353650lfj.22.1687735082587; Sun, 25 Jun 2023 16:18:02 -0700 (PDT) Received: from localhost.localdomain ([2a02:2168:b344:a600:4435:f106:1598:d2b0]) by smtp.gmail.com with ESMTPSA id eq6-20020a056512488600b004f86d546458sm851547lfb.6.2023.06.25.16.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 16:18:02 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 3/5] hurd: Fix calling vm_deallocate (NULL) Date: Mon, 26 Jun 2023 02:17:49 +0300 Message-ID: <20230625231751.404120-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230625231751.404120-1-bugaevc@gmail.com> References: <20230625231751.404120-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, 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 server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Only call vm_deallocate when we do have the old buffer, and check for unexpected errors. Spotted while debugging a msgids/readdir issue on x86_64-gnu. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/readdir64.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sysdeps/mach/hurd/readdir64.c b/sysdeps/mach/hurd/readdir64.c index 2c01ca22..2d946793 100644 --- a/sysdeps/mach/hurd/readdir64.c +++ b/sysdeps/mach/hurd/readdir64.c @@ -64,9 +64,13 @@ __readdir64 (DIR *dirp) /* The data was passed out of line, so our old buffer is no longer useful. Deallocate the old buffer and reset our information for the new buffer. */ - __vm_deallocate (__mach_task_self (), - (vm_address_t) dirp->__data, - dirp->__allocation); + if (dirp->__data != NULL) + { + err = __vm_deallocate (__mach_task_self (), + (vm_address_t) dirp->__data, + dirp->__allocation); + assert_perror (err); + } dirp->__data = data; dirp->__allocation = round_page (dirp->__size); }