From patchwork Thu Jun 6 15:38:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688683 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAC00196C63 for ; Thu, 6 Jun 2024 15:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688320; cv=none; b=CQLtR8dgejjJYTLH0WCDO8uc5xiu6sWj59qTcye/Z/MlLojOM/0l74xkMnYNbzQlELW+mob+5I+HtTS+qitWusUio8OLndpA4pM6c+Izr50a28X+5x8eqLtJFMdZFk96VhSt2ME+M3hWDZycxMjzTeMRjyIgry3Aly+G4bWSFVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688320; c=relaxed/simple; bh=Ewmr86j6zQiow2wK/o8Yf2Cxz4qrAUxB6Inmq5gkrW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B8bYKzkq89uhuaVWy/jf1q2h/OKc4MGAU7cufpczSus5CjQ87TBhYJFLlm8dq+oeNNjuPfzf6SFjrddZpOudpgkpK9rWbmhJ0bqzM/DPBBbSqgFVcniRZAHLqBrEsupHjwMDPVCJRGbJuGjybMkeTL3vGYDrvxD6gB6ikra68u0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Et79uojM; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Et79uojM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688317; 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=HgpeHS1N7ftisvO29XBLOP8taTOvhyj7LfctCgVWeXk=; b=Et79uojMcev8edaDV/uODS+5AtXNMh8NSfDeHxYbQJTmq9cZUI7GLWf53pS875+tJJ5u0f u/KPS738qH2lvfJd/4nv7v6P3YhIxFh1a7qIhvEnRFAIzE9soPaRkeTLFI/pZ8lIG55Un5 cUYxyoah8V1EU7pLrYfAZ/JyzK3wU6o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-0zHbpkl-N6SZqhlWjZwuZQ-1; Thu, 06 Jun 2024 11:38:36 -0400 X-MC-Unique: 0zHbpkl-N6SZqhlWjZwuZQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B7B68007A1; Thu, 6 Jun 2024 15:38:36 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id 60E0F40C6DB3; Thu, 6 Jun 2024 15:38:34 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:33 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 01/15] libtracefs: call va_end() before exiting tracefs_hist_set_sort_key() Date: Thu, 6 Jun 2024 17:38:15 +0200 Message-ID: <20240606153830.2666120-2-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Each invocation of va_start() must be matched by a corresponding invocation of va_end() in the same function. If add_sort_key() fails, tracefs_hist_set_sort_key() exits without calling it. Call va_end after add_sort_key() fails. Fixes a VARARGS error (CWE-237) Signed-off-by: Jerome Marchand --- src/tracefs-hist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index 2b4f17f..87287b5 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -596,8 +596,10 @@ int tracefs_hist_set_sort_key(struct tracefs_hist *hist, if (!sort_key) break; tmp = add_sort_key(hist, sort_key, list); - if (!tmp) + if (!tmp) { + va_end(ap); goto fail; + } list = tmp; } va_end(ap); From patchwork Thu Jun 6 15:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688684 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0A61196C63 for ; Thu, 6 Jun 2024 15:38:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688322; cv=none; b=it7CQuM+mWNlR4MNSmdFx3QA7ycVmn3sUncQEOs6Feinzq0NF6Ry+bh/N+CKz5whcfjJtzgGWdwVJMQW4o3BWCTfs8s8EZo6C+rUxsQ8slklDdGFVmpLdQ/qidSMHE5tID1/kp1gA/tvn1xip+mk6VdgjmdvN7zx7LFVfGVU0lA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688322; c=relaxed/simple; bh=u/XT+upAt/XhCK2A9tHFGo14sFCWtkGrrAjR6Xm0dNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uvCkF43L08KZEOolNItYHWS8IMaIAZQhLJ1tD3CRa6SlE+074D4/ykMlbyTdulo272RAwEoEHIScglZwgayMch2+FNZLKsAnMQ/4Cjplq1dFdUCut95lHwChmU76QXjR9IUhH+KiZwp+JM4mGqZf4Z39iX/CEYuUEarPiIU3FyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VxQzFXf5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VxQzFXf5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688319; 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=nAAbFqK7A/rR5+429z/wUXmQQGe2oIVPaGz9NoJ6P9I=; b=VxQzFXf5ucsS4EFpoSKlgDv2bl2bJjP8eIu/eOre/Fjx13mvdZbaXQ5J+ALioExAFRfGWr UjK9ASPdo6emYXT+nYkCi66MIVRe7PJpPylbMuuwzMgIPJV4xwkxTsNxQrtTHZj3NthCh7 awEh+XJqUt1NtEYqzoB1dpri4DQvC1Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-PXQrbIpGOrajbskwKyMUHQ-1; Thu, 06 Jun 2024 11:38:38 -0400 X-MC-Unique: PXQrbIpGOrajbskwKyMUHQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55DE185A588; Thu, 6 Jun 2024 15:38:38 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id CD0FB1C14B13; Thu, 6 Jun 2024 15:38:36 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:36 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 02/15] libtracefs: prevent memory leak in append_filer() Date: Thu, 6 Jun 2024 17:38:16 +0200 Message-ID: <20240606153830.2666120-3-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 The buffer containing the new filter isn't freed if we encounter an error after it was allocated. Free tmp in the error path. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-filter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tracefs-filter.c b/src/tracefs-filter.c index afe3338..1b1c60e 100644 --- a/src/tracefs-filter.c +++ b/src/tracefs-filter.c @@ -250,12 +250,12 @@ static int append_filter(char **filter, unsigned int *state, case TRACEFS_COMPARE_NE: tmp = append_string(tmp, NULL, " != "); break; case TRACEFS_COMPARE_RE: if (!is_string) - goto inval; + goto free; tmp = append_string(tmp, NULL, "~"); break; default: if (is_string) - goto inval; + goto free; } switch (compare) { @@ -277,6 +277,8 @@ static int append_filter(char **filter, unsigned int *state, *state = S_COMPARE; return 0; +free: + free(tmp); inval: errno = EINVAL; return -1; From patchwork Thu Jun 6 15:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688685 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E516B196C72 for ; Thu, 6 Jun 2024 15:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688327; cv=none; b=rN8dJwtzXBlEBM+qdnCdaZc079OtALunZLwiWirdcjT/mIQ6gYoljJbufZzuJMTJqMHv5fygC7x/xFdfupf2T449w3XA7/YeLJYq2vIhD8yAMLHJ5JVxZ1LjPOkox0Vnilaym0G3oykD39uX+xdQr25unTReOcckoE3+IwvYaoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688327; c=relaxed/simple; bh=++fBaxswMezW4ifKm7jt7ksGc+f5fR3mMxP7agOyqyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=shf68QQ5YI718vklUbDjwzi4llY+lMIc8dpEJfUzt9YOxfPt6nSLfgmLqsQkLgY8qBZUkfqzHl+Oxo5A4VnN6+NsHtxtYe0z+5zCOz3ArgVGA2Jh7iW5hEOI9+wqSRybSZL1Vrnv0KAFISTjL0CTCJZG8Mimjxpp2FH/iKTnUgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VtN/3tkj; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VtN/3tkj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688324; 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=FpGU0sBNWte/Y1Z9ColYRXl6cataNb8y3taFahUFRdU=; b=VtN/3tkjUG/c73PSTSLE2cO4TcnvMKxhYhEZuis8Bvc40fIbACg7PKmabAQlNtSjj0rNnG ow6Jrg0GrqO0HNq5tckiN20a1R4JEkuXmPP77k/3U3RK4hPQI+LFT2EFwid0NrfRdwkJj2 zb7uPzvOk6ewr3hBiKzKHZwUyPRh3uk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-nsswVTfqO727B09gdM56XA-1; Thu, 06 Jun 2024 11:38:43 -0400 X-MC-Unique: nsswVTfqO727B09gdM56XA-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E9CCA19344B7; Thu, 6 Jun 2024 15:38:41 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id BFD521955F4B; Thu, 6 Jun 2024 15:38:39 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:38 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 03/15] libtracefs: prevent a memory leak in update_fields() Date: Thu, 6 Jun 2024 17:38:17 +0200 Message-ID: <20240606153830.2666120-4-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 In update_fields() p isn't freed is store_str fails. Since p is to be freed whatever the result of store_str() might be, move the call to free() before checking field_name. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-sqlhist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c index ecf09ce..c7b9eff 100644 --- a/src/tracefs-sqlhist.c +++ b/src/tracefs-sqlhist.c @@ -810,9 +810,9 @@ static int update_fields(struct tep_handle *tep, if (!p) return -1; field_name = store_str(sb, p); + free((char *)p); if (!field_name) return -1; - free((char *)p); } tfield = tep_find_any_field(event, field_name); From patchwork Thu Jun 6 15:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688686 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FD86196431 for ; Thu, 6 Jun 2024 15:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688332; cv=none; b=d1Yy0dpxVa++HXeVnK+C5vps64ofmNT6XMAgi4KsqothCDQPN660+pihXPDPnNQYudtY8eFyx0L59sYxJA+9tGh6g3l2rR5MF91tuc48yvjYMQOmqM8xYDvZBGobAYgE093YY0WOufXwLZ3k+jnXiyaYDa8yBqisRSm+hPpkPRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688332; c=relaxed/simple; bh=w99eGZVHB3/m1/fKVXKV/Iedx9+G+KUaZZ4KaRSueMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OIiM73F2tRxkWMzd2YWxAppCznAtTnOzNnco/2eFATBgTJUbutwHBw48l+FSlJ5IJZppr2y+wUGnhc3nT4YlGlL70dci+vx4OXo6WSBW7F1IpPCJ57gwyxquMPtyU6bNtexNrDeKi2ZXcgGxTyjin0RxMy4fAlmLAyv6gX5FZMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=W0rQIKRR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="W0rQIKRR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688330; 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=Std32kvFskPbELW2vLz8Q7n/5y+g6fqTm3ibXyw4jFs=; b=W0rQIKRRbfo691zKI6qZ2XFDojlnPG8CeeKGl+4DCubxAHKsCZyhMrPWEsPSv/FMNaQyFY wiXvukmUstBIOR919G+ZaqrSlFFHvQw0rokb5969ZV3CRB8UdpT6JGd9B2Wz368jPigBFL muCmuq1r+YKnN5kGQAffttbTRrZeqKQ= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-MqqbcWurN7-yBt5iLV0S2w-1; Thu, 06 Jun 2024 11:38:46 -0400 X-MC-Unique: MqqbcWurN7-yBt5iLV0S2w-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1512196DFFA; Thu, 6 Jun 2024 15:38:45 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 597881959178; Thu, 6 Jun 2024 15:38:43 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:42 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 04/15] libtracefs: prevent a memory leak in tracefs_synth_add_end_field() Date: Thu, 6 Jun 2024 17:38:18 +0200 Message-ID: <20240606153830.2666120-5-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Free tmp_var in the error path. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-hist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index 87287b5..4f4971e 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -1576,7 +1576,7 @@ int tracefs_synth_add_end_field(struct tracefs_synth *synth, const struct tep_format_field *field; const char *hname = NULL; char *tmp_var = NULL; - int ret; + int ret = -1; if (!synth || !end_field) { errno = EINVAL; @@ -1594,15 +1594,15 @@ int tracefs_synth_add_end_field(struct tracefs_synth *synth, tmp_var = new_arg(synth); if (!trace_verify_event_field(synth->end_event, end_field, &field)) - return -1; + goto out; ret = add_var(&synth->end_vars, name ? hname : tmp_var, end_field, false); if (ret) goto out; ret = add_synth_fields(synth, field, name, hname ? : tmp_var); - free(tmp_var); out: + free(tmp_var); return ret; } From patchwork Thu Jun 6 15:38:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688687 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30357196431 for ; Thu, 6 Jun 2024 15:38:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688334; cv=none; b=I1QvA22qLNCBCHUhpDbIs1W1RKHhAsyE10DWXgyxSjbkCEp0IZ1/vTvXqx7fNEHZX3T0Y5uXAxVM1TO7TBwsZ533zBolZCt+PRtgaGRoR4H40cpZg9rCPVQAmK438+Qur8/hB2xHgIR7cBODkR6U0o+d/EXr5N6PXeIKxfRcFAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688334; c=relaxed/simple; bh=18AzkRgaAke3cBnUqay5+gNFxHqRxfLKs8mb98pxjfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mAe7RT6U5+Wil0cQaPXLfLCnxoSpMbTA8WYmXi/+RfTn5H5J1q2S7o8Leu+926UArXkC8P3AuNgje0NoYMoZaog1lg0cmCNft7LLZoG8KfUpmhYjbPT7o5kvj09iBmG4FPL/xNzX9gE6ty/SdWmnq14aiPVa6FnTgklL1cuAKcw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Vfsnpf6o; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vfsnpf6o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688332; 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=SPLw7DWy9dG19j+4ii7z3zh95dwYvNfHg9GrffDdtag=; b=Vfsnpf6o1bveh/QdLJpprFAaD+U6+1PLn/WLgFyi5y8lz2FueX1DfxmeBEkyrzb0FWOR9f m0Kp62W5uj+qIWHVV2C1d2wXqclp2qM0Z/UN4AOemXFAL/MQkZ9xaXYD2ia3YAgZ0RN1o0 FWMGKb+3PFqAdjL+jShM7/DFBDniH1A= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-IG-DJejSMLizfjVhSEfogw-1; Thu, 06 Jun 2024 11:38:49 -0400 X-MC-Unique: IG-DJejSMLizfjVhSEfogw-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0A89C19344B7; Thu, 6 Jun 2024 15:38:49 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id DFCDF1955F4B; Thu, 6 Jun 2024 15:38:46 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:45 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 05/15] libtracefs: prevent memory leak in tracefs_event_systems() Date: Thu, 6 Jun 2024 17:38:19 +0200 Message-ID: <20240606153830.2666120-6-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 If an error is encountered in the loop, enable and sys might not get freed. Move the calls to free() before possibly exiting the loop. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 1b1693c..906dbe8 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -854,12 +854,12 @@ char **tracefs_event_systems(const char *tracing_dir) enable = trace_append_file(sys, "enable"); ret = stat(enable, &st); + free(enable); + free(sys); if (ret >= 0) { if (add_list_string(&systems, name) < 0) goto out_free; } - free(enable); - free(sys); } closedir(dir); From patchwork Thu Jun 6 15:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688688 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FC39196DAA for ; Thu, 6 Jun 2024 15:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688338; cv=none; b=d4xSeXypyG85Df+wr728lEKaGwBTgvO2Cqa4PFkErHzvllGPsSrVHzIv5jL95f/YE1DsmevIbFs4rCFSobaGr81850V0XODF/sSuu9TwYGiE+s0Fz7rWfJ0QgT4Zyqe9Inv7lcxeLvyy3EVtKh+uFkUkmmbZ88Wi79ZZc1gUUF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688338; c=relaxed/simple; bh=mA+NmsKenoalLv++MAAk2NzT60ktY8LmNgcAlCHXWiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LrvObk8e8qEQsNi61G+B8LnnFxHjvMLzDXoLYc8/pVTuE+muoPgrgI4mmHIWYEv770tg5/JCL3yIdBjNEjEDV7U8R2zZpCT3CIIrb/0kLX6PslZ5OugZoHzquzH1pr6VeMm8lYP+3wn+JKl+r/prsWmU60gxC7A51ZjxrE+2Ux4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IE5mbfAT; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IE5mbfAT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688336; 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=YqmvRulF+1oPzhby+vjXwSbcyWnJ7OsoW6q+Hwa3YnM=; b=IE5mbfAT4u8KDP0mPBuMq5+uLB6J9DtfFceTe8LjC/u1YoQZBJTw7151LkhmhjKRyCiHnc rrUGpV4FG51WastmGLwUmzD5cRdXNF26xYhiAnE5OU4k6YJ5JBeS1A6Egs5fRLl8IIC/iw 1fnV4aIkvyxpL2/UIKki2lBrsbKFLEE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-EbMHsZecMS6AOhfm4eIigQ-1; Thu, 06 Jun 2024 11:38:53 -0400 X-MC-Unique: EbMHsZecMS6AOhfm4eIigQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86E2C1933B7A; Thu, 6 Jun 2024 15:38:52 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 72E953001E83; Thu, 6 Jun 2024 15:38:50 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:49 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 06/15] libtracefs: don't leak socket file descriptor in open_vsock() Date: Thu, 6 Jun 2024 17:38:20 +0200 Message-ID: <20240606153830.2666120-7-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Close the socket file descriptor if connect() fails. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-vsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tracefs-vsock.c b/src/tracefs-vsock.c index e171382..9171321 100644 --- a/src/tracefs-vsock.c +++ b/src/tracefs-vsock.c @@ -19,8 +19,10 @@ static int open_vsock(unsigned int cid, unsigned int port) if (sd < 0) return -1; - if (connect(sd, (struct sockaddr *)&addr, sizeof(addr))) + if (connect(sd, (struct sockaddr *)&addr, sizeof(addr))) { + close(sd); return -1; + } return sd; } From patchwork Thu Jun 6 15:38:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688689 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6634D196D8A for ; Thu, 6 Jun 2024 15:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688342; cv=none; b=SvSDXtwj3mfG3CrNh+Atui28QKWEbfL4qFzvpwmjaB5TadpstULJM6VrAEXE+xAo0zBedbF0+aKzvTx6/6sdS8tXqbwgnJsnbxggZUVUB81jvFSF2uv89ouHZzZ+XR+cMuW0dPwCzeFTQt267MbdxaETps12uFb7Wnqjb4MAhDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688342; c=relaxed/simple; bh=jcUhe8CYyc2S7hAiJU6etdoZIrGAKYJIAEHT9t+RU4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fe54sLe902oJ5suXhAOE8mBQgpsceAis+rknicy9HKiOL9giaChS/r38Zak4aJIw+yGhLZzK/87D2HH6UKbRB0lLn8BaII4Bwzz6IsSHgKHnhTI1PpNFCN/bJIr6PdYQZPDVLiErdDSJEVqBDuns9IXN0JxYQUcnGpTR3pd7Bhc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Yq5cp2d/; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yq5cp2d/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688340; 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=hIOYXlopohATiNkq0HhmOG3e2v3g3FQOPNyFDvL4G4Q=; b=Yq5cp2d/a+b/Ul30M18OOoWRtuFaq8w/pKdOWzKcxMp7GJI6sw+As0A+5knyoONCGG2bd0 IoKJrGjmJuSBwvWRkIouRam7XcvGyhWhzbYWg87/t8VmB0o+xfRlfuOEcw8l2CYJEfSgz4 Yqswpu6YGDajapXi0bp8CORWeIrSd2k= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-bPrcq3K7MQOC9bVBG1UruA-1; Thu, 06 Jun 2024 11:38:57 -0400 X-MC-Unique: bPrcq3K7MQOC9bVBG1UruA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7C87D19772E9; Thu, 6 Jun 2024 15:38:56 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 423D73001E9F; Thu, 6 Jun 2024 15:38:53 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:52 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 07/15] libtracefs: prevent a memory leak in add_func_str() Date: Thu, 6 Jun 2024 17:38:21 +0200 Message-ID: <20240606153830.2666120-8-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Free func_list if strdup() fails. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-tools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index 8e7b46d..74cfe91 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -559,8 +559,10 @@ static int add_func_str(struct func_list ***next_func_ptr, const char *func) if (!func_list) return -1; func_list->func = strdup(func); - if (!func_list->func) + if (!func_list->func) { + free(func_list); return -1; + } *next_func = func_list; return 0; } From patchwork Thu Jun 6 15:38:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688690 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EFF919751B for ; Thu, 6 Jun 2024 15:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688344; cv=none; b=pkpR9XSaoEhbKZq3hPByADC2srLQKzuDtbT+nen5GJVbLpGRM8CtvcWI9i3VOazJbaRDKCq9oCDEzg+MtR6eAqb5Hdpf9jb4SODDXXOFJAAilcJ+hFdAxX3a4duZ9UaCtsNP9rTaZBTEomV3oMUF8crQgGwv7GsmvAv+vcCnW2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688344; c=relaxed/simple; bh=/ifqdhaIhlOJEMZltC6M7aVyrEPCDtHUsk5TNSMWouI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GEWqCeokSrAJ73jqV0UhD6LgNBTwPG6ZeCH+J6fzVs42c0H0Zl29vQWze9nIjhaohnfscbWtvleT3B4wpG1J1LBGzAm7drQcZLc5YXQlq/n+gwnDoO8wng6mNiVeSlmpRauUPM+fpVa//vmNCuv3s6Uj7AB0SE8VKOWto8zh0VE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MUJ1wNZS; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MUJ1wNZS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688342; 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=ir6+4hsmkyruWgqCfhI30dqK9/Mhw+EE/HIzqYyct1Q=; b=MUJ1wNZSfSrGvBNkZX9wRWDlgoHuELydN6tEUdqACb6lIbVUSTc9AReXA9lRjVdCAUW+FD qI07EXefgBN5ga6NsHNqD7oWvkBCGu9cdYSocpCK+0X6luLkOcl/cL5Vx6t6IyKCyY6g9c dQVDaHQvKboBFu2Hr+of2rxqGBCRN4c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-n-7FdQaVPxWT1XBBRkzDrA-1; Thu, 06 Jun 2024 11:38:59 -0400 X-MC-Unique: n-7FdQaVPxWT1XBBRkzDrA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CACED85A588; Thu, 6 Jun 2024 15:38:58 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id 53E2BC15E6C; Thu, 6 Jun 2024 15:38:57 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:56 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 08/15] libtracefs: prevent a memory leak in tracefs_system_events() Date: Thu, 6 Jun 2024 17:38:22 +0200 Message-ID: <20240606153830.2666120-9-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 If add_list_string() fails, event isn't freed. Free event before calling add_list_string(); Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-events.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 906dbe8..d65837e 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -919,11 +919,10 @@ char **tracefs_system_events(const char *tracing_dir, const char *system) free(event); continue; } + free(event); if (add_list_string(&events, name) < 0) goto out_free; - - free(event); } closedir(dir); From patchwork Thu Jun 6 15:38:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688691 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A2A0196D87 for ; Thu, 6 Jun 2024 15:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688344; cv=none; b=OniS1RTsoNhI2DE/JPLdvBVz6QP0YzbQElNSdEnX0MkN5ZLNS9yOO0bKO7YEKIYh48o+z0SuwU2xgkoJIfNGDAe9d0YHwY+dfNBAKQHQLncyb9Uj4i6Ubq2u8whCAk9jMkJs3vQfG+ogf5zFUTI6HZmQAUzAemWZgxirIkX6ZPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688344; c=relaxed/simple; bh=76EKUrRL1XamIUM8RujyYePYVhatPFCtxjDdQFrzIqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MXWswgx7tSVJEgCaLbRDYAW4QBu15jHSCybzZRHVK7VdGz2ca2z9brEAWEIqbODby42EWRBuSDl/dnhgFC7ATl441FI+FV6x/Fhg3UFu5oKH/tKupU8LyO/RezVxMC6/l29xmL+vV7chl6eR8LEuD+70ORwzr+kS5rFiW7kaL4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AC4D5V8G; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AC4D5V8G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688342; 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=JB+3lrO0vznp2Mfy985Tf1ZPgPBJ+0IFH15r+gGUUVI=; b=AC4D5V8Gp2RlGkTwWY1mfTJD5Db1YJZWNtAVADaaQsYBTUZ7qGks7iWqWY2fvRVys4UeTf h4VlSJd1ociMOCqg/Zw8+h04tEKujygKZdacU3Cn5+d5H8k77Jyh7vR+UqNHbeyrkQv4wl 06KzpFDwC2pYi8yl8Jhtc+mo5ioTtM0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-RekuX3xfNe-q_8bHvzb5sw-1; Thu, 06 Jun 2024 11:39:01 -0400 X-MC-Unique: RekuX3xfNe-q_8bHvzb5sw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07D27800074; Thu, 6 Jun 2024 15:39:01 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id 8588640C94A8; Thu, 6 Jun 2024 15:38:59 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:38:59 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 09/15] libtracefs: prevent a memory leak in open_cpu_files() Date: Thu, 6 Jun 2024 17:38:23 +0200 Message-ID: <20240606153830.2666120-10-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 In open_cpu_files(), if realloc() fails the latest allocated tcpu isn't freed. Rearrange the loop to prevent that. Signed-off-by: Jerome Marchand --- src/tracefs-events.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index d65837e..88325e1 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -275,9 +275,12 @@ static int open_cpu_files(struct tracefs_instance *instance, cpu_set_t *cpus, tcpu = tracefs_cpu_snapshot_open(instance, cpu, true); else tcpu = tracefs_cpu_open_mapped(instance, cpu, true); + if (!tcpu) + goto error; + tmp = realloc(*all_cpus, (i + 1) * sizeof(*tmp)); if (!tmp) { - i--; + tracefs_cpu_close(tcpu); goto error; } @@ -285,9 +288,6 @@ static int open_cpu_files(struct tracefs_instance *instance, cpu_set_t *cpus, memset(tmp + i, 0, sizeof(*tmp)); - if (!tcpu) - goto error; - tmp[i].tcpu = tcpu; tmp[i].cpu = cpu; i++; @@ -296,7 +296,7 @@ static int open_cpu_files(struct tracefs_instance *instance, cpu_set_t *cpus, return 0; error: tmp = *all_cpus; - for (; i >= 0; i--) { + for (i--; i >= 0; i--) { tracefs_cpu_close(tmp[i].tcpu); } free(tmp); From patchwork Thu Jun 6 15:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688695 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C30B1974EB for ; Thu, 6 Jun 2024 15:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688357; cv=none; b=kL+oMMP5azRCKW2ySceJY/PMNRjkQKFmc7OYUZOMrQxeviAQ/xdaTZKJKCAuJrZpr3WalJHrJLOCK2te6C8lDd26g88w2ds23rX8dVIr9S7CKNtx5ljkyrhyUd8J7R2faLarRk9XCVUYWGjSIgHrSDN2E3+Ai6hySNIoJEzO2cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688357; c=relaxed/simple; bh=ixoFcq5Za3Kis52ofTp5WWflVDqpQo/p/OwVBlzwAGI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8RwF5Za/u4HxrqurdtOtzQ2JGcIKoEw/Cszq9f1WuIrPfcDHOxuD+njrpBw9ky458oLX+/XKHvAMsnj5ZT48SVwnWFUt7X2W4WWVK9onL66ZrBPT63bXQJ0de7C0FzgfHBB+mKx1XnZa/IDLc66nCReqdYp+Og36JF2a04pnF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Rkgqyr4P; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Rkgqyr4P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688355; 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=Tb2t9eT+nSFKssGnBMHtIgoxY8BqFU3dYVJ5aFVCeJE=; b=Rkgqyr4PSEu1cM4cdIQC0KH2MEiMFg9iJ9ZEHZVXrbeWy92JU53OmwuOGmL+lbcC4OmNwO klEUko7B8i85j+lvSJvKhHXN86kXrfCFtNMq5xfaf3FIqJdxVm6xk1p4CPMT6oN9uSTohW 2kYemNWq8HU7gQ0FzPEC+7ZJkh4EtS0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-QAWA5OhaNt2jxNOeMa67iQ-1; Thu, 06 Jun 2024 11:39:13 -0400 X-MC-Unique: QAWA5OhaNt2jxNOeMa67iQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E1AB518BF039; Thu, 6 Jun 2024 15:39:12 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 672B7197701E; Thu, 6 Jun 2024 15:39:02 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:39:01 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 10/15] libtracefs: prevent memory leak in tracefs_instance_create() Date: Thu, 6 Jun 2024 17:38:24 +0200 Message-ID: <20240606153830.2666120-11-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Free the path of the instance directory in the error path. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-instance.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c index 9a26708..dd7decd 100644 --- a/src/tracefs-instance.c +++ b/src/tracefs-instance.c @@ -217,6 +217,7 @@ struct tracefs_instance *tracefs_instance_create(const char *name) return inst; error: + tracefs_put_tracing_file(path); tracefs_instance_free(inst); return NULL; } From patchwork Thu Jun 6 15:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688692 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF23F1974F3 for ; Thu, 6 Jun 2024 15:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688351; cv=none; b=qiRHZvT+uc69bDoX05Rh54UPlGk1WFp47xbkR0sTE6ih2Z+AoCBBv5hSJQNcVmDhltfwO43yeyCD9ahzcSZJOmidunxXbtU33/VeAmjdNR9GBn11a9hmzox9BavYxQg8YxkV/ianL0rDzmREY58swK0LJf2sU8YI7l8zl01yRVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688351; c=relaxed/simple; bh=yrX6kDRd2G8fU7XqzPjMOuSWSYzU68/qoF/fsG/YUTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ow1waVjHfDPmk1aNzU+h4NCboh9FZ6mygyD82k4484NnYhvsltixFXPg3TVIZApya/ueZUpStfDokNIYBbdauh9TY4V7Nc9cJBm4/yB6BILS5Cx5e/qdkTSUz3RgCJbQql6omZoEtG5SDQ9OpDahhrpNHDPoc9g9dCYMAKKfMTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JxYOyxR2; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JxYOyxR2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688348; 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=LmYRpy4iSBTJwKNTfg19TEah0tV2QFO45n2YJW61IWY=; b=JxYOyxR23WzIRDKMm/aT5HwADExXbOgErxs6btAJbRm/XYV2hhU9DKDePvOPbGGYPHE+4o 4woqjIADLy4qYhdPEYIMg4Rmjew+ru+mYsVTLiUHyFM7dQEmV86Z8mec2peiOjiP+COqW6 WeeGzMi/pbpjXswVicc4nl5H/WYjz84= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-xQG8EOa_PAqxKn3xaLfKeA-1; Thu, 06 Jun 2024 11:39:07 -0400 X-MC-Unique: xQG8EOa_PAqxKn3xaLfKeA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3849A801F9C; Thu, 6 Jun 2024 15:39:07 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id B5AD517ABA; Thu, 6 Jun 2024 15:39:05 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:39:05 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 11/15] libtracefs: my_yyinput() should return 0 when no data can be read Date: Thu, 6 Jun 2024 17:38:25 +0200 Message-ID: <20240606153830.2666120-12-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 YY_INPUT() is redefined in sqlhist.l and basically just call my_yyinput() to do the work. However, YY_INPUT is supposed to return YY_NULL (0 on Unix system) when no data can be read, not -1. This can cause an overflow error in the generated sqlhist-lex.c file. Have my_yyinput() returns zero when no buffer is found. Signed-off-by: Jerome Marchand --- src/tracefs-sqlhist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c index c7b9eff..0f678c1 100644 --- a/src/tracefs-sqlhist.c +++ b/src/tracefs-sqlhist.c @@ -121,7 +121,7 @@ __hidden int my_yyinput(void *extra, char *buf, int max) struct sqlhist_bison *sb = extra; if (!sb || !sb->buffer) - return -1; + return 0; if (sb->buffer_idx + max > sb->buffer_size) max = sb->buffer_size - sb->buffer_idx; From patchwork Thu Jun 6 15:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688693 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15FF1196431 for ; Thu, 6 Jun 2024 15:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688353; cv=none; b=Lf0wEZN3Ob1V5qVGqLzmf6EqHhI++WjNdVIL2TXGnwm9vQ6Wcf/fQx0IjRi8fz4e71ToGGcqPi5sCtmbJ3/htPuw058mCpePChni7KyxG6Chmt6r0XMQH/sAXcHHJCElCv9d4qzLtPPTt7FxAqjmVuPBiqUArpAGnDquHz2vgVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688353; c=relaxed/simple; bh=k5CY2NF9fSYWzIIP8tbpKKz11oAGtj12r0e9ZtIix68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bU7lPf/JOTL6U/kEODEEpAc21KiAuO/mbLUkrtOmAyyZgT4FtE9P6qv2sAvQfeBKHiSAIQDmeMfQ99M0VD2X0nAnW8Jl5lU1hx4V0rkWirJJw0m60Y+b/IRDeoNB/9/gicVd0FqgGuK+TEPBhiUMYkIxBUzC+7hVRtlXNesXRPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JTAzjMfu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JTAzjMfu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688351; 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=zbkjbZfzlbGT/XDsHf6clPJO8PId3qEXpzHdZWGjWXs=; b=JTAzjMfulm6pyFoG5znBSjMeeM896x3t8mBXCm0G9JYcjbekTxhoaq49d7aBCQHN5c6i6v QczxBQ4GJ1aQ2lu4V4gx7JmSnwk8Rc0HKLfuQgLEhQWwZQ0exzwvQ/HOdUtLwlLvtLZuDz 06M7Iu4h9IuBSWymR5wMqZLsYRIxcUU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-l0xOJXApNP-HHC6JwXrueg-1; Thu, 06 Jun 2024 11:39:09 -0400 X-MC-Unique: l0xOJXApNP-HHC6JwXrueg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A46829AA387; Thu, 6 Jun 2024 15:39:09 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id E7FFBC15E6C; Thu, 6 Jun 2024 15:39:07 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:39:07 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 12/15] libtracefs: prevent memory leak in tracefs_dynevent_get_all() Date: Thu, 6 Jun 2024 17:38:26 +0200 Message-ID: <20240606153830.2666120-13-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Free events in the error path of tracefs_dynevent_get_all(). Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-dynevents.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tracefs-dynevents.c b/src/tracefs-dynevents.c index 7a3c45c..85c1fcd 100644 --- a/src/tracefs-dynevents.c +++ b/src/tracefs-dynevents.c @@ -589,6 +589,7 @@ tracefs_dynevent_get_all(unsigned int types, const char *system) return all_events; error: + free(events); if (all_events) { for (i = 0; i < all; i++) free(all_events[i]); From patchwork Thu Jun 6 15:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688694 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1889F1974F3 for ; Thu, 6 Jun 2024 15:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688357; cv=none; b=UmLQrWBimadNXNOrzy+wVNrljezT5Yttva+1c7u9l5hKb7YGMNfKOgl70wZrpsU4jPQgXZzLQ3tDZaHlgAcCQa+kgzuESADI9vxpoAmYWWRI/uw/7CuP0kLzhb7Sl9CWXgf+CPbhE1euSLB2F5qWJL0N4+7tWDE6/YQkwRYxuN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688357; c=relaxed/simple; bh=gntECSRBiIbB760dVGvzw5GbzWB7/9C/0YHOD7hdKYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JIAA3S1PHi44h1c/AYKIVEXjToJoY8MloxlUxLte9f7SzK9KUF5yZuEBwikOynMTNQAHLoskNPBGzKn6l8QWjwqJ3cMup7dAa8lY9ulsHigjzSrsH84BRQd/bq+NlQ+n8AI2MMg2qk5F4Itbhd4uHjIN+XRD4jR+W5FqQVDcO+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QXC+WWJf; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QXC+WWJf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688355; 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=mBhcsA3Ov3CAAQPCz4pGtUcTfYYi4vZNRs8juWNtZ5I=; b=QXC+WWJfZ5AqJ6K7/jqnR1pbkqOryfOxOcB2E+crfz1rAccaBlrE4ncNYOQp+L01ch9T57 3uns9CwsTDorK1CY+ZED46P5M7bqiUsWPJNep75RygzV2H9P1ZXvzBIKWHDATZZwpYtgj7 6iJxR/Em8+kxRZJCbwSB7JbHuNeV050= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-axKibFk9NVemIZ9TOl0QxA-1; Thu, 06 Jun 2024 11:39:12 -0400 X-MC-Unique: axKibFk9NVemIZ9TOl0QxA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8AD729AA387; Thu, 6 Jun 2024 15:39:11 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id 3DCAE37E0; Thu, 6 Jun 2024 15:39:10 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:39:09 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 13/15] libtracefs: close dir in the error path in tracefs_system_events() Date: Thu, 6 Jun 2024 17:38:27 +0200 Message-ID: <20240606153830.2666120-14-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 In tracefs_system_events(), we don't close dir if add_list_string() fails. At this point, just breaking out of the loop fixes that. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 88325e1..1fa3f2f 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -922,7 +922,7 @@ char **tracefs_system_events(const char *tracing_dir, const char *system) free(event); if (add_list_string(&events, name) < 0) - goto out_free; + break; } closedir(dir); From patchwork Thu Jun 6 15:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688696 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 831821974EB for ; Thu, 6 Jun 2024 15:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688359; cv=none; b=QOztcF5sLhSZLGOJ04H4KeWR6AYPIJW4Hoqb3pZ3VP9iwtT4pxNx40A27Urb+gI52lQ+2ptRPIswNKxZoXwAdvB6iK3QKKeMHTVJiMkEE3tqIAFeu5uFgWidgUKvt3JUYB6+SI6UgwpW638MbnD8JPj/dZj8opgjVoW5j0u7pFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688359; c=relaxed/simple; bh=XnTtbowSY0Il+/Zt4mRvEVEN8hgiBMuwZh/vp3+kspo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a5Aa9EYMQTwFk2+uYlAuB3mRzOdFCTdIIHtKT5R8XUDHkUSV7/+jTE+qpaE8TXyEPQlThjIjuQUo44Gv9pim3wcct50EqU7TQdG5FuV9ECql4SCZH6SfT5IbBpgM1/ZfkllMJormAM4pJjqZ4kMg6GEsx1gmkRA5ojlDWJEyK70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Lzsexon1; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Lzsexon1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688357; 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=wMXoK4xT6xU5YFiykxdbcTn+yoGIHWsG2EbjWfo+0n0=; b=Lzsexon15DkeUR1ShAfPBmHfNcm78tI6J4iDYN+mWEsHSecScyv9ymIoq9j4x/MDo2LA3T iMApYCxw8MVIBpVQu8tlGAt8PE3+qEKRlDwHH6kSwYTBATMlgv8Xkz31xEiXUtqW4kQ5bz KtyxS/zt+ptGvwyOJKQcaYTN2pgqNpM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-kHGMfV3lOn-W-EHzI5zzcA-1; Thu, 06 Jun 2024 11:39:14 -0400 X-MC-Unique: kHGMfV3lOn-W-EHzI5zzcA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAEA418539F7; Thu, 6 Jun 2024 15:39:13 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by smtp.corp.redhat.com (Postfix) with SMTP id 744A123D5B; Thu, 6 Jun 2024 15:39:12 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:39:11 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 14/15] libtracefs: close dir in the error path in tracefs_event_systems() Date: Thu, 6 Jun 2024 17:38:28 +0200 Message-ID: <20240606153830.2666120-15-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 In tracefs_event_systems, we don't close dir if add_list_string() fails. At this point, just breaking out of the loop fixes that. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand --- src/tracefs-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 1fa3f2f..83069aa 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -858,7 +858,7 @@ char **tracefs_event_systems(const char *tracing_dir) free(sys); if (ret >= 0) { if (add_list_string(&systems, name) < 0) - goto out_free; + break; } } From patchwork Thu Jun 6 15:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Marchand X-Patchwork-Id: 13688697 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B101974EB for ; Thu, 6 Jun 2024 15:39:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688366; cv=none; b=qokDPn8kQa2lN7iCcdmDj5qHEB0/0MILVueaTzFDV9oslsYNsHYdVhqDZPKcPLi71w4dhAZdV8uYbCN4znNkigq+YCt8M4Il8nyH9Jk9wKpNOyZRoPD1M3JG6VAopwTnkbWne4qGsL6MipB/JzTfASQwe5n5trfpHU6gTZcS3nc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717688366; c=relaxed/simple; bh=unNRAobtsTNpQ1l2uEscTLqhtB94EpwMAKjNQ9L4b3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pFm89IPs63jVZY10B1cFRfn5tbAwL9z4tvH3+jhWGlYcrFysFBAXOfQjZIXI6qBj0GiGrqDRZ+b9+OHRnkqrrrh/CH/ZWerbMsP0Emk1hx2zxprm4xKtIhyI/lATjJQqp+1iwHde4L8Hm4mo4FeK6KvpCD0zmZKIagx7rxAxYlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=E4xqqnct; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E4xqqnct" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717688364; 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=NsFrhqfv+GimEite5FlAHvC8rOxISXCzfyG5HXm/oxc=; b=E4xqqnctinBnj3leqeMOzppi/c2YiIx3rL5jqf63k1El2F88MRXmBWCJZvvbelHHHgYEvj +j5C/2Okcv6qOgfMnounwO/7rcE2MtTv7XqkwIA6MjvJS8h4e1vklyxVnAwkyyjEbPLv1g x6WkGz5TnsIe7nmMHqHcZG4mEQj20iQ= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-FXGH0r_rPUiX5Bqvhw8YiA-1; Thu, 06 Jun 2024 11:39:22 -0400 X-MC-Unique: FXGH0r_rPUiX5Bqvhw8YiA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D4484185CB83; Thu, 6 Jun 2024 15:39:21 +0000 (UTC) Received: from fedora (unknown [10.45.224.84]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 8F5A6190BA8A; Thu, 6 Jun 2024 15:39:15 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 06 Jun 2024 17:39:14 +0200 From: "Jerome Marchand" To: Linux Trace Devel Cc: Steven Rostedt , Jerome Marchand Subject: [PATCH 15/15] libtracefs: initialize val in build_filter() Date: Thu, 6 Jun 2024 17:38:29 +0200 Message-ID: <20240606153830.2666120-16-jmarchan@redhat.com> In-Reply-To: <20240606153830.2666120-1-jmarchan@redhat.com> References: <20240606153830.2666120-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 In build_filter(), val is only initialized if filter->rval->type is either EXPR_NUMBER or EXPR_STRING. AS far as I can understand that is expected at that point. Howvever, it doesn't cost much to initialize it in case the parser let some bogus request pass by and it should prevent the static analyser to complain. Signed-off-by: Jerome Marchand --- src/tracefs-sqlhist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c index 0f678c1..08bd0fa 100644 --- a/src/tracefs-sqlhist.c +++ b/src/tracefs-sqlhist.c @@ -1109,7 +1109,7 @@ static int build_filter(struct tep_handle *tep, struct sqlhist_bison *sb, const char *val); struct filter *filter = &expr->filter; enum tracefs_compare cmp; - const char *val; + const char *val = NULL; int and_or = TRACEFS_FILTER_AND; char num[64]; int ret;