Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5442174rwb; Tue, 1 Aug 2023 02:37:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlHVm4UwZtfcbDiiQeIgXovV/1RlAmaP1YjLoN4K/XnxK5FvJt1UtmYXsXyM9OMSSWilGm83 X-Received: by 2002:a17:902:8e85:b0:1b9:e97f:38ac with SMTP id bg5-20020a1709028e8500b001b9e97f38acmr11100506plb.56.1690882624922; Tue, 01 Aug 2023 02:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690882624; cv=none; d=google.com; s=arc-20160816; b=p5aCbQtHHHQkTrtoX6Z1VOmNsB3OXgoBhAkTXT/FKRltfVHhdw6eRCMb52AN5HzhTV 8w6b4S16QVyP6W6p8A6c0otKcYOKcEjoOxlRBHNThzOLQkg82U/KsBPn4y6JCl8Q+OLh 4v+1oq43jIF2LmGW171KBGq/4gbUXuSVJqFCd8yrusKcpD2UlEEyrCMbJRe4v9NfHrBa Ys6Y5aI9JsR2zfgYhmzNdB7xyp3/mp83neoUceIr8KiNrxHUP5OSPNMHAIFfgQOQEsKp vGFsFIg6HKCtKpX1UYzy/bdDmIR47oxvYcy3+QAm5kDGQ4arMFDpRlFlJGkWDBOtm9zc h1mA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kBySKfhMpW5e5BOzvL+uiOpVyslDNpoO3k4O/PgFgMc=; fh=xsWU7TL3uUtBfXq6K37JjH+wk7kY2gfBvddvmxUz2rI=; b=p4RiyGhIUAVUxJUE9tIhneSbA+drUNdstH93D3klLHzg5L/gLFKIahmKPndXcjqQwJ wFEbeXUZuhcLDePdYkLbscl2uozpzJOTcHnZ0QBYFfUF8vGjVyWqJcTUqvccIqQyh8Qh nztEtHXw1UeQRNjyzF8aF+AtwD8pT7hGw0lSkAIJ4u/dImGE7maAtUq/4ncH2ccTrfOj ZaHOJwYO7ng71ebXfzuOS0jiUZ3xWKyTUxvS3ZZeV3nJnwJnYTkl879o4yahyWljraLi CkTYEoxNpkdv5hiDDAkAfMQ+6EKj7cmcXhMmTJvA3CG/IwJEYkqPMV8VF1V3L1ThHbzy dHrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pk2chotH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a170902ead100b001bb0ff2b354si8648318pld.425.2023.08.01.02.36.45; Tue, 01 Aug 2023 02:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pk2chotH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232883AbjHAJgo (ORCPT + 99 others); Tue, 1 Aug 2023 05:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbjHAJgR (ORCPT ); Tue, 1 Aug 2023 05:36:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200EE1BF9 for ; Tue, 1 Aug 2023 02:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690882421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kBySKfhMpW5e5BOzvL+uiOpVyslDNpoO3k4O/PgFgMc=; b=Pk2chotHaD7pVpKYfQPpxs39C7dzL+KA9OAEiwsGgnbVRsLrPbu2RoS/4Jpmh9fi9nJc31 htnF1ZWMDj7MEsicN+TCk9aHAi2bbVolvNkQi4wA3KTxv1+0aPZgoUFr1t1m1KDEXtcK5W 1v6f4eIkxGdPNyOXPOKa4bJhP8ZFNRs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-gPZOl14YNtag0SxcyP-NYg-1; Tue, 01 Aug 2023 05:33:38 -0400 X-MC-Unique: gPZOl14YNtag0SxcyP-NYg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B181D185A78B; Tue, 1 Aug 2023 09:33:37 +0000 (UTC) Received: from localhost (yoyang-vm.hosts.qa.psi.pek2.redhat.com [10.73.149.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19AE9492B03; Tue, 1 Aug 2023 09:33:36 +0000 (UTC) From: Yongcheng Yang To: Steve Dickson Cc: Linux NFS Mailing list , Herb Wartens , Yongcheng Yang Subject: [PATCH 1/2] rpcb_clnt.c: fix a possible double free Date: Tue, 1 Aug 2023 17:33:09 +0800 Message-Id: <20230801093310.594942-2-yoyang@redhat.com> In-Reply-To: <20230801093310.594942-1-yoyang@redhat.com> References: <20230801093310.594942-1-yoyang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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-nfs@vger.kernel.org Signed-off-by: Herb Wartens --- src/rpcb_clnt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c index d178d86..630f9ad 100644 --- a/src/rpcb_clnt.c +++ b/src/rpcb_clnt.c @@ -252,12 +252,16 @@ delete_cache(addr) for (cptr = front; cptr != NULL; cptr = cptr->ac_next) { if (!memcmp(cptr->ac_taddr->buf, addr->buf, addr->len)) { /* Unlink from cache. We'll destroy it after releasing the mutex. */ - if (cptr->ac_uaddr) + if (cptr->ac_uaddr) { free(cptr->ac_uaddr); - if (prevptr) + cptr->ac_uaddr = NULL; + } + if (prevptr) { prevptr->ac_next = cptr->ac_next; - else + } + else { front = cptr->ac_next; + } cachesize--; break; } -- 2.31.1