From patchwork Thu Nov 3 14:12:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Frank Ch. Eigler" X-Patchwork-Id: 59835 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 6D7B33857C69 for ; Thu, 3 Nov 2022 14:12:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D7B33857C69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667484752; bh=qajnExnoNAdFQ0gkUxBqpHqLeolmmBq5+qeXO8UgZ5k=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=yRZH/UvbeFbswDeFFznWSpTU7ui2TcIHLEgjJC/keM+NQ/7gpg98YoYJ+ToBl2YuF 5NZLsULJk/RwFvg/u/WbKiYqvDYYLcdIKQirzB5hJwefeEqhxEAub9p0XrHUoTWQn/ bF38zQj8qNsg63Ju5i2xRb5ZHlChHx4P3NJpBFdc= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 409883858299 for ; Thu, 3 Nov 2022 14:12:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 409883858299 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-531-rQxzJC3zPFSXwmtZEurjGQ-1; Thu, 03 Nov 2022 10:12:20 -0400 X-MC-Unique: rQxzJC3zPFSXwmtZEurjGQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 366A02A5957E for ; Thu, 3 Nov 2022 14:12:20 +0000 (UTC) Received: from redhat.com (unknown [10.2.16.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 277191121325 for ; Thu, 3 Nov 2022 14:12:20 +0000 (UTC) Received: from fche by redhat.com with local (Exim 4.94.2) (envelope-from ) id 1oqax9-0008RN-8k for elfutils-devel@sourceware.org; Thu, 03 Nov 2022 10:12:19 -0400 Date: Thu, 3 Nov 2022 10:12:19 -0400 To: elfutils-devel@sourceware.org Subject: patch, debuginfod Message-ID: <20221103141219.GA25265@redhat.com> MIME-Version: 1.0 User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Frank Ch. Eigler via Elfutils-devel" From: "Frank Ch. Eigler" Reply-To: "Frank Ch. Eigler" Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Hi - Showing diff -w to omit reindentation whitespace noise. Maybe worth backporting to 0.188 releases, could affect federation intermediate servers with burst workload. commit ec166cf3c8d825a2f02aca448a0823de12e78991 (HEAD -> master) Author: Frank Ch. Eigler Date: Thu Nov 3 10:07:31 2022 -0400 debuginfod.cxx: fix coverity-found use-after-release error The debuginfod_client object lifetime needs more careful handling, made easier with the defer_dtor<> gadget. Signed-off-by: Frank Ch. Eigler diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 1efa080fe337..4d576caec2a5 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2022-11-03 Frank Ch. Eigler + + * debuginfod.cxx (handle_buildid): Correctly manage lifetime + of debuginfod_client federation callout object. + 2022-11-02 Mark Wielaard * debuginfod-client.c (extract_section): Mark static. diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index f46da6eff4a7..02a11477a515 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -2249,8 +2249,10 @@ handle_buildid (MHD_Connection* conn, int fd = -1; debuginfod_client *client = debuginfod_pool_begin (); - if (client != NULL) - { + if (client == NULL) + throw libc_exception(errno, "debuginfod client pool alloc"); + defer_dtor client_closer (client, debuginfod_pool_end); + debuginfod_set_progressfn (client, & debuginfod_find_progress); if (conn) @@ -2323,11 +2325,6 @@ and will not query the upstream servers"); (const unsigned char*) buildid.c_str(), 0, section.c_str(), NULL); - } - else - fd = -errno; /* Set by debuginfod_begin. */ - debuginfod_pool_end (client); - if (fd >= 0) { if (conn != 0)