From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9AD59462AC for ; Mon, 24 Feb 2025 17:40:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93F8C427A8; Mon, 24 Feb 2025 17:40:40 +0100 (CET) Received: from mail-ej1-f98.google.com (mail-ej1-f98.google.com [209.85.218.98]) by mails.dpdk.org (Postfix) with ESMTP id CFCB14278E for ; Mon, 24 Feb 2025 17:40:37 +0100 (CET) Received: by mail-ej1-f98.google.com with SMTP id a640c23a62f3a-aaec111762bso123252066b.2 for ; Mon, 24 Feb 2025 08:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1740415237; x=1741020037; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/AtbEytKxo55iAjaV8ekKqqFZln+jcXYUmALl5RLNuI=; b=SsFJoz7iItEevQcX5B8/evHU1D9fGURy8w+3cz3wIWid/ghiYNJT6eVWpFt7pQgO0z wF7xF79lYnk/U8gAMvwRI/W/40EQ2BZBQGydQw7P8aMeXpXBUmia1e+YZKwPYyEqgMnG VSISdFBtZaJpJQ3I9hZhf52/0HM0PIQYgGM2jJ4x7ekUcauKPIeGG7H2fUGaiXYkNWuY cVYLYQ0sdaLF95F2dKXdGUOQg+v4yXc1oSzJoXzapq1uBRe7UEuBWUxKbFgBTDURN8sb O9+rtoXyUaWQsQzOfVy9kWcANnZ5VxT059rnBQTQnS/8DBuYn6VPLCdzPgd8HSxwtzbq l3Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740415237; x=1741020037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/AtbEytKxo55iAjaV8ekKqqFZln+jcXYUmALl5RLNuI=; b=ZSzzNgba6Da+joYY1MHeAKIRRkwZcXN8aOhnliEWpgzf2YbmbV14Jieh1rlRpax/hk HZNxO7xOjyrn2bGF3HaoJLF4OvK5VFWezk3SU4f+gmKd9A3zayaABK5fmAIRk7jgI3iU 0DSaJitbMysCtDA0yjPwjP23KyMAPkloeSlqGGDBFzutk8GIJqxbzT2yVVZYGjavfKTW J7aY822Zmw2g8Hlb5jtZcFXLRTXYmxYBhB5fofTXarqNs73th323shLTlETnbrivrl0O EDHRxXTHEc+4tnZT03nTHROjlRVhV/YTL9om1AQ/LE61tZ9iChGdkarQu4rYZomvVvFd IuoA== X-Forwarded-Encrypted: i=1; AJvYcCVreSDqIrZWDRqDov/RdL0K0SMf1mlQ45/kYXmqfM56J5iGs5EFYmJAHQFwm5GELff7JHuLSSg=@dpdk.org X-Gm-Message-State: AOJu0Yy4xUJ/iqlxi3yeojdFm/pSiSyz5YEaT3Oj5RupuLsRCYJJl18A GfCOM+kyUATKKOaUMNCrues+SzavDJ/BH9Ihc9EEyKYYD/K/8SwhBhOLXVEVROdz/yAocLv1uF3 bZaZ97tMSHh5ZWh5Vig7Z2O5ZIIhwSYEn X-Gm-Gg: ASbGncvlumMxV80azhqmiLTwZ9GGuu1VneSpocyzITE//Iv6iV9I+5D6ctahqPEjiBG Nzae5JS+4fpDMrVO+GKhoBRSf9hRtVELd8QShRqp9wsuDdAiXh1Gi7Kkld/KaQsS3MBzDBXW+4q nhYd9+H+5/j+wch44zPeC6Ctx8/yhonLF+4KQm0qlN2miQPU6ymrX4PbCyXQ4WQUMFYoAY67kaM T9NERqB7DRw2tMUEhtzfeyE9r/PnOstPAZux7q/FQgGue6vA1lGNuycuqPfkI9yUzck4fKIx9hi gwwRluYwiX9TZ9U0G7s0wYAH48ygDt99HDuBelZRfb6h7FpJUrQKxNpT2X/k X-Google-Smtp-Source: AGHT+IGvS7Zq583Ox/kY2Ho4bq0Y/iUW3Zj5rSiN1mseedJnWP7GFzVy65Tn5G1Fa/8KVTQgiTqU5LtTEf1d X-Received: by 2002:a17:907:7fac:b0:ab7:eeae:b23e with SMTP id a640c23a62f3a-abc09e53506mr1266483866b.47.1740415237421; Mon, 24 Feb 2025 08:40:37 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id a640c23a62f3a-abeca18aefasm2811866b.222.2025.02.24.08.40.37; Mon, 24 Feb 2025 08:40:37 -0800 (PST) X-Relaying-Domain: 6wind.com Received: from localhost (rainbow.dev.6wind.com [10.17.1.165]) by smtpservice.6wind.com (Postfix) with ESMTP id 47F3D15754; Mon, 24 Feb 2025 17:40:37 +0100 (CET) From: Ariel Otilibili To: dev@dpdk.org Cc: Thomas Monjalon , David Marchand , stable@dpdk.org, Stephen Hemminger , Reshma Pattan , Dmitry Kozlyuk , Ariel Otilibili Subject: [PATCH v3 1/1] pcapng: fix null dereference in rte_pcapng_close Date: Mon, 24 Feb 2025 17:40:31 +0100 Message-Id: <20250224164031.587829-2-ariel.otilibili@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250224164031.587829-1-ariel.otilibili@6wind.com> References: <20250216160833.3216001-1-ariel.otilibili@6wind.com> <20250224164031.587829-1-ariel.otilibili@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org rte_pcapng_close() might dereference a null pointer; as example, PVS-Studio gives its usage in test_pcapng.c: indeed, that call to rte_pcapng_close() might receive a null pointer. Link: https://pvs-studio.com/en/docs/warnings/v522/ Link: https://github.com/DPDK/dpdk/blob/e5176f23ae8b31437c3e5eb875c81f95bf3a9942/app/test/test_pcapng.c#L438 Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files") Suggested-by: Stephen Hemminger Signed-off-by: Ariel Otilibili --- .mailmap | 2 +- lib/pcapng/rte_pcapng.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.mailmap b/.mailmap index a03d3cfb591b..ea68d6180ccc 100644 --- a/.mailmap +++ b/.mailmap @@ -135,7 +135,7 @@ Anupam Kapoor Apeksha Gupta Archana Muniganti Archit Pandey -Ariel Otilibili +Ariel Otilibili Arkadiusz Kubalewski Arkadiusz Kusztal Arnaud Fiorini diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 16485b27cb46..66c16ba2277d 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -716,6 +716,8 @@ rte_pcapng_fdopen(int fd, void rte_pcapng_close(rte_pcapng_t *self) { - close(self->outfd); - free(self); + if (self) { + close(self->outfd); + free(self); + } } -- 2.30.2