From patchwork Mon Apr 11 15:17:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12809317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEB00C433F5 for ; Mon, 11 Apr 2022 15:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347475AbiDKPUP (ORCPT ); Mon, 11 Apr 2022 11:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244798AbiDKPUO (ORCPT ); Mon, 11 Apr 2022 11:20:14 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3177326C8 for ; Mon, 11 Apr 2022 08:17:59 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id v4so5361974edl.7 for ; Mon, 11 Apr 2022 08:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uz0Qj4HqGj8zZuxN93G4U/BHoUPzN/AMV7S8css1VRc=; b=K2c58GFB1sNql49nIZe7fcbDZU9Nv2r1ZcNytKOh5ZysDJxhTV4C+TjjqoTJJ1sxZz UHvF07ga2CXKA4R41ZMcNktI8+dNh+IWotbvPVe9anSeSs1HoIYzHlDzstlXwk+koc1T ehp7LwHnLbBrXiadNgSldbBe/h3T4qwu+HCL0LKUsA9T9haUARxxy3Nj9i7oHw+rEQmo RMJoGjYlLkYrgnEMOVj17hWblj/rutZfITnIkYrY5l0lG+pIuI1vmJj4A+6TT5gRoP1J ViU3CLTKiJRXHrn7SQAN7uaA5/KxhzOv4BSk6uN1F0mBMlumMGLPmnBcZ87egexlV3QK yU4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uz0Qj4HqGj8zZuxN93G4U/BHoUPzN/AMV7S8css1VRc=; b=gvMoOIehwWm5PKbFiV41VKYW7qD1DksR2zEtrcEr5FmAu3L/Sa9cECSeJhVdrdDfSq pzrnIYImqMc0V3uOV2oMQgCGz9LLSv55UyqH2qQVh/SjwklzGE0vxam8ygJr21w+ouur EsxkuB+K1lyvOZJqBwGxBLNv9tSXZKFxp58+iAW1QIbG2PQ8J3VddBbqWoO08SqMM0XC PzWrDJgU8rFKIOWkoWtwHk4NgRXCWdUmQjMvpV+1imRgXTTdSjyIIxx7irN9Vy5a+X2v Qtlnp+K7w1hcxr8yw7FjiHU/1HO9SFT0Mt+lDUTLlZJRNh4JxSHzG5cjIS1sWdJP+x8s +Fkg== X-Gm-Message-State: AOAM532L2d4Ut/YLaQciFyxLHyeZC+XtGtqgmrBsltKLnZKVrX0zYbuT y5br4715VDGslX2+KIiu0z38v6qZ+vc= X-Google-Smtp-Source: ABdhPJwtF5q/iK2jkgtF0+qJECv2gMo4eaFE00sPlQbn1NbUnAjN9ebmt2ajE2Smz7EKlO9WMU0how== X-Received: by 2002:a05:6402:2688:b0:419:5dde:4700 with SMTP id w8-20020a056402268800b004195dde4700mr34123419edd.124.1649690277890; Mon, 11 Apr 2022 08:17:57 -0700 (PDT) Received: from crow.. (78-154-13-168.ip.btc-net.bg. [78.154.13.168]) by smtp.gmail.com with ESMTPSA id s12-20020a1709062ecc00b006e8558c9a5csm3867262eji.94.2022.04.11.08.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 08:17:57 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 1/2] kernel-shark: Do not hard-code app name Date: Mon, 11 Apr 2022 18:17:43 +0300 Message-Id: <20220411151744.445930-1-y.karadz@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Instead, use 'cmakedefine' the export the corresponding Cmake build variable. Signed-off-by: Yordan Karadzhov (VMware) --- build/deff.h.cmake | 3 +++ src/kernelshark.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build/deff.h.cmake b/build/deff.h.cmake index 82379df..4302f00 100644 --- a/build/deff.h.cmake +++ b/build/deff.h.cmake @@ -11,6 +11,9 @@ /** KernelShark Version number. */ #cmakedefine KS_VERSION_STRING "@KS_VERSION_STRING@" +/** KernelShark Application name. */ +#cmakedefine KS_APP_NAME "@KS_APP_NAME@" + /** KernelShark installation prefix path. */ #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@" diff --git a/src/kernelshark.cpp b/src/kernelshark.cpp index c373f54..1ad15f4 100644 --- a/src/kernelshark.cpp +++ b/src/kernelshark.cpp @@ -56,7 +56,7 @@ int main(int argc, char **argv) int c; QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setDesktopFileName("kernelshark"); + QApplication::setDesktopFileName(KS_APP_NAME); QApplication a(argc, argv); KsMainWindow ks; From patchwork Mon Apr 11 15:17:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12809318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04EECC433FE for ; Mon, 11 Apr 2022 15:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244798AbiDKPUP (ORCPT ); Mon, 11 Apr 2022 11:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238081AbiDKPUP (ORCPT ); Mon, 11 Apr 2022 11:20:15 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2AFD326CC for ; Mon, 11 Apr 2022 08:18:00 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id z99so10253006ede.5 for ; Mon, 11 Apr 2022 08:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OVAcQKlhbG6CW9HL0Y9R8dGb1SN0GZHF1cI9ZN5wH1Y=; b=C69vkHKz0WjRW9rRPB2RucmGsbnBTE2vpryo/w8bswpef8IZjdKKiXqX2nseNlM6I7 sXidqWMBOhG+ZO3muV8aA/DtXE/OAg78FtiNUhzpwucB/hwlOQYx6Y7mr2Ep2qd+MsVH IuUn4roeFogBu4SNNhay7EWHLcyUxRVAkmLeOjzQcLxZHGi69aQqfeacABw7qTYPIqJd Gt54oA4TwdNyEEIzFynBJTxKiejZdiCkRzvcMR7rkvCy2c3aFLc4WW1PKqtwfzEU5a39 5KNCrjrTC+oASOqpl7VAoy4FpT9JgQhyaY2y+9YYOVZoynpzmN3159QAQZRXDoWffJ8p AC3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OVAcQKlhbG6CW9HL0Y9R8dGb1SN0GZHF1cI9ZN5wH1Y=; b=d5VZvK1L5PHDET0oi0vGwFbxmeVdpK3t/0Teg6OvICr4GTROrVO5XLdkK17dc+ByQ4 ZoqkgKddwXyG2zCcE3joVK41+cqwpaa2IqjH+MM2VmRkLVOhLjtXXuBiIBRYKVUXtX/c O3VUj7xnyrx+dVooiwMHPj+P3g0a/sY7hnjMAe1J1oHJZ03NHPIm8jhvM+6l65BWidSb FhyDEefZXf64B6YlIH+w8BUHqeYL+PqhUFvjvZw3ThL2wK9HFGZdYTppIKXWw5o2rSGd X0LAYCSqLcFd1kU4bhOUqvAz1G+QfXgGSNAucoG4qVoNQQWAgce/hCddUZARQNbvE23f RzgA== X-Gm-Message-State: AOAM532/Db/OQPaZPKq2MSZ1N6nQOBf1wDFVm4AgeTKTBeHd7RnMKzeV upW8/5trghsZHXFofYW7nl3ekAXLz6A= X-Google-Smtp-Source: ABdhPJy+cqtSG5C/6ByFrYrHDIQZBaKPO0c6HW5JR8ZmfNWxAQ0NPdLdv4GBzbPSSFgp20EH8o4Tyw== X-Received: by 2002:a05:6402:1b07:b0:41d:7abf:8337 with SMTP id by7-20020a0564021b0700b0041d7abf8337mr5997239edb.185.1649690278974; Mon, 11 Apr 2022 08:17:58 -0700 (PDT) Received: from crow.. (78-154-13-168.ip.btc-net.bg. [78.154.13.168]) by smtp.gmail.com with ESMTPSA id s12-20020a1709062ecc00b006e8558c9a5csm3867262eji.94.2022.04.11.08.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 08:17:58 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org Cc: "Yordan Karadzhov (VMware)" , yinkui.zhang@xedge.ai Subject: [PATCH 2/2] kernel-shark: Fix memory corruption in KsCaptureDialog Date: Mon, 11 Apr 2022 18:17:44 +0300 Message-Id: <20220411151744.445930-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220411151744.445930-1-y.karadz@gmail.com> References: <20220411151744.445930-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The list of local plugins, returned by tracefs_tracers() must be freed using tracefs_list_free(). Reported-by: yinkui.zhang@xedge.ai Signed-off-by: Yordan Karadzhov (VMware) --- src/KsCaptureDialog.cpp | 6 ++---- src/libkshark-tepdata.c | 5 +++++ src/libkshark-tepdata.h | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/KsCaptureDialog.cpp b/src/KsCaptureDialog.cpp index ca4c2bc..651f811 100644 --- a/src/KsCaptureDialog.cpp +++ b/src/KsCaptureDialog.cpp @@ -222,12 +222,10 @@ QStringList KsCaptureControl::_getPlugins() if (!all_tracers) return pluginList; - for (int i = 0; all_tracers[i]; ++i) { + for (int i = 0; all_tracers[i]; ++i) pluginList << all_tracers[i]; - free(all_tracers[i]); - } - free(all_tracers); + kshark_tracecmd_plugin_list_free(all_tracers); std::sort(pluginList.begin(), pluginList.end()); return pluginList; diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c index 08aca09..b435a29 100644 --- a/src/libkshark-tepdata.c +++ b/src/libkshark-tepdata.c @@ -1724,6 +1724,11 @@ char **kshark_tracecmd_local_plugins() return tracefs_tracers(tracefs_tracing_dir()); } +void kshark_tracecmd_plugin_list_free(char **list) +{ + tracefs_list_free(list); +} + /** * @brief Free an array, allocated by kshark_tracecmd_get_hostguest_mapping() API * diff --git a/src/libkshark-tepdata.h b/src/libkshark-tepdata.h index 1b955be..c67c06b 100644 --- a/src/libkshark-tepdata.h +++ b/src/libkshark-tepdata.h @@ -51,6 +51,8 @@ void kshark_tep_filter_reset(struct kshark_data_stream *stream); char **kshark_tracecmd_local_plugins(); +void kshark_tracecmd_plugin_list_free(char **list); + struct tep_handle; struct tep_handle *kshark_get_tep(struct kshark_data_stream *stream);