From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 563E4A05D3 for ; Tue, 21 May 2019 16:47:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB7785592; Tue, 21 May 2019 16:47:16 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id F0E674F91 for ; Tue, 21 May 2019 16:47:15 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id u17so9195946pfn.7 for ; Tue, 21 May 2019 07:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8330PcApY6ka1Sn7moWEczC9dE9Y7TQKC1zU7koWEhw=; b=KggU5gwykXb270Zaw9jF2kExJA3xr81mlgzO9Xsh8yTguUZrMpgiXiWYzPWMLKUWaM SWOzwMYByiFRXYK+pAz8ZOQPaglKjT923brmOFmDPVskQIe0S96nSo5RLK57zY1h0NXk RRwJchzMfqD4/hE/CeIGuk9i6rkzhVJbxvjeJO7dvHbFCslEgxL+vZGkXWLCETEjLVMf HFCKXQNLkfrzNFMnm7jYHr7QCcjDeQ0eeDkl7t4ui5I1RNTLvA6EW6P98TUZ72h5fzNs TvbZY5rmJBpRY8pvcnYETMabgaWGuRWBlcXLwwjBnzU1nOzQnTy+30RtLwJs0/ag058g 476w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8330PcApY6ka1Sn7moWEczC9dE9Y7TQKC1zU7koWEhw=; b=NrEBU+rpFElLeUKaOC8l0i/BSJwOiQgjabFaw1CkBLzkp45+Z7/PxZuBWwJnImHeNi QICHhec7/FcdZ805UcxoJCxy8NBtmFiW9J+zmutWxPX88WQVU9ysTBjD/8H7gpkNFNVG QeHw5Iv+WYA5E6Hjbpl0N6Ao5G/jkn5y6wMDefCPSYltuydx1Ndfhh/1IqelYaL7nalh Yh6iziA3vNduM+k4PvS+cs0jOF7kBpshD9jUl1nZMALR59sevetHGZsRYGXfKggxj62Y 0cGO+nAYoBzrv8I8yJBdEjOyLVW36sQX80peh0jD+npgD7ZH4bvnDnOSKR8RG9Qtn+YY jVkg== X-Gm-Message-State: APjAAAXoO6KKCa0T9UWtplcp6YnuTTVF4ZmoGKLkACJLXggRUh/YdJUW XkP5UZ6fo2N1ogEYDk/RZ3+xKw== X-Google-Smtp-Source: APXvYqxRa4jwJ6rJtv4Mm5eamw6Ja6nwdAGVa6Gcg3GvUejSo/A3jMrF4YqxUATsk8scobLJQbaXlw== X-Received: by 2002:a63:730f:: with SMTP id o15mr82689634pgc.315.1558450035141; Tue, 21 May 2019 07:47:15 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t2sm17749176pfh.166.2019.05.21.07.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 07:47:14 -0700 (PDT) From: Stephen Hemminger To: lee.daly@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 21 May 2019 07:47:13 -0700 Message-Id: <20190521144713.12046-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] compress/isal: fix use after free X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The release function was using qp->stream after already releasing it and the null pointer checking was missing. Also since rte_free(NULL) is a no-op, remove unnecessary checks for NULL. Coverity issure: 340860 Fixes: dc49e6aa4879 ("compress/isal: add ISA-L compression functionality") Signed-off-by: Stephen Hemminger --- drivers/compress/isal/isal_compress_pmd_ops.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c index fe9995992304..77ac6fcf21fc 100644 --- a/drivers/compress/isal/isal_compress_pmd_ops.c +++ b/drivers/compress/isal/isal_compress_pmd_ops.c @@ -171,18 +171,12 @@ isal_comp_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id) if (qp == NULL) return -EINVAL; - if (qp->stream != NULL) - rte_free(qp->stream); - - if (qp->stream->level_buf != NULL) + if (qp->stream) rte_free(qp->stream->level_buf); - if (qp->state != NULL) - rte_free(qp->state); - - if (qp->processed_pkts != NULL) - rte_ring_free(qp->processed_pkts); - + rte_free(qp->state); + rte_ring_free(qp->processed_pkts); + rte_free(qp->stream); rte_free(qp); dev->data->queue_pairs[qp_id] = NULL; -- 2.20.1