From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org,
linux-perf-users@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
German Gomez <german.gomez@arm.com>,
Ian Rogers <irogers@google.com>, Ingo Molnar <mingo@redhat.com>,
Jiri Olsa <jolsa@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>
Cc: cocci@inria.fr, LKML <linux-kernel@vger.kernel.org>
Subject: [cocci] [PATCH] perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp()
Date: Thu, 13 Apr 2023 15:02:55 +0200 [thread overview]
Message-ID: <54a21fea-64e3-de67-82ef-d61b90ffad05@web.de> (raw)
In-Reply-To: <1a11455f-ab57-dce0-1677-6beb8492a257@web.de>
Date: Thu, 13 Apr 2023 14:46:39 +0200
Addresses of two data structure members were determined before
corresponding null pointer checks in the implementation of
the function “sort__sym_from_cmp”.
Thus avoid the risk for undefined behaviour by removing extra
initialisations for the local variables “from_l” and “from_r”
(also because they were already reassigned with the same value
behind this pointer check).
This issue was detected by using the Coccinelle software.
Fixes: 1b9e97a2a95e4941dcfa968c4b2e04022e9a343e ("perf tools: Fix report -F symbol_from for data without branch info")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
tools/perf/util/sort.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 80c9960c37e5..f2ffaf90648e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1020,8 +1020,7 @@ static int hist_entry__dso_to_filter(struct hist_entry *he, int type,
static int64_t
sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
{
- struct addr_map_symbol *from_l = &left->branch_info->from;
- struct addr_map_symbol *from_r = &right->branch_info->from;
+ struct addr_map_symbol *from_l, *from_r;
if (!left->branch_info || !right->branch_info)
return cmp_null(left->branch_info, right->branch_info);
--
2.40.0
next prev parent reply other threads:[~2023-04-13 13:03 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-09 18:30 [cocci] Checking pointer dereferences with SmPL Markus Elfring
2023-04-09 18:41 ` [cocci] Reconsidering pointer dereferences before null pointer checks (with SmPL) Markus Elfring
2023-04-09 18:45 ` Julia Lawall
2023-04-10 5:25 ` Markus Elfring
2023-04-10 6:25 ` Julia Lawall
2023-04-10 7:33 ` Markus Elfring
2023-04-10 8:00 ` Julia Lawall
2023-04-10 12:10 ` Markus Elfring
[not found] ` <alpine.DEB.2.22.394.2304101415040.2875@hadrien>
2023-04-10 12:48 ` Markus Elfring
2023-04-11 7:15 ` Markus Elfring
2023-04-11 7:40 ` Julia Lawall
2023-04-11 9:47 ` Dan Carpenter
2023-04-12 9:15 ` Markus Elfring
2023-04-11 13:36 ` [cocci] [PATCH 0/5] drm/amd: Adjustments for three function implementations Markus Elfring
2023-04-11 13:42 ` [cocci] [PATCH 1/5] drm/amdgpu: Move a variable assignment behind a null pointer check in amdgpu_ras_interrupt_dispatch() Markus Elfring
[not found] ` <c265e914-4ba4-1af8-a504-21dd859f0226@amd.com>
2023-04-11 14:45 ` Markus Elfring
2023-04-11 13:43 ` [cocci] [PATCH 2/5] drm/amd/display: Move three variable assignments behind condition checks in trigger_hotplug() Markus Elfring
[not found] ` <edf173d9-8b59-ecab-99d0-1063b51574a9@amd.com>
2023-05-16 16:40 ` Markus Elfring
2023-04-11 13:46 ` [cocci] [PATCH 3/5] drm/amd/display: Delete three unnecessary variable initialisations " Markus Elfring
2023-04-11 13:48 ` [cocci] [PATCH 4/5] drm/amd/display: Delete a redundant statement " Markus Elfring
2023-04-11 13:50 ` [cocci] [PATCH 5/5] drm/amd/display: Move an expression into a return statement in dcn201_link_encoder_create() Markus Elfring
2024-01-05 19:21 ` [cocci] [PATCH 0/5] drm/amd: Adjustments for three function implementations Markus Elfring
2023-04-11 16:38 ` [cocci] [PATCH] drm/msm/dpu: Delete a variable initialisation before a null pointer check in two functions Markus Elfring
2023-04-11 17:43 ` [cocci] [PATCH] qed: Move a variable assignment behind " Markus Elfring
2023-04-13 12:10 ` [cocci] [PATCH] ASoC: SOF: topology: Move a variable assignment behind condition checks in sof_dai_load() Markus Elfring
2023-04-13 13:02 ` Markus Elfring [this message]
2023-04-13 15:17 ` [cocci] [PATCH] tipc: Reduce scope for the variable “fdefq” in tipc_link_tnl_prepare() Markus Elfring
2023-04-13 19:10 ` [cocci] [PATCH] gfs2: Move a variable assignment behind a null pointer check in inode_go_dump() Markus Elfring
2023-04-13 19:44 ` [cocci] [PATCH] video: au1100fb: Move a variable assignment behind a null pointer check in au1100fb_setmode() Markus Elfring
2023-04-13 20:20 ` [cocci] [PATCH] media: atomisp: Move a variable assignment behind a null pointer check in atomisp_cp_general_isp_parameters() Markus Elfring
[not found] ` <ZDmJsemYldOsMMrH@smile.fi.intel.com>
[not found] ` <9b243f3e-92ad-197f-f0a6-b22eaf71238a@redhat.com>
2023-04-16 18:01 ` Markus Elfring
2023-04-19 7:49 ` [cocci] " Markus Elfring
2023-04-19 15:50 ` [cocci] [PATCH] " Markus Elfring
2023-04-14 9:16 ` [cocci] [PATCH] scsi: hpsa: Move two variable assignments behind condition checks in hpsa_scsi_ioaccel_raid_map() Markus Elfring
2023-04-14 10:12 ` [cocci] [PATCH] nvdimm: Replace the usage of a variable by a direct function call in nd_pfn_validate() Markus Elfring
[not found] ` <ZDlvunCNe9yWykIE@aschofie-mobl2>
2023-04-14 16:50 ` Markus Elfring
[not found] ` <ZDmmMhFTg5TaikRl@aschofie-mobl2>
2023-04-15 7:52 ` [cocci] " Markus Elfring
2023-04-14 15:02 ` [cocci] [PATCH] media: adv748x: Move a variable assignment behind condition checks in adv748x_hdmi_query_dv_timings() Markus Elfring
2023-04-18 10:00 ` [cocci] [PATCH v2 0/3] media: adv748x: Adjustments for adv748x_hdmi_query_dv_timings() Markus Elfring
2023-04-18 10:02 ` [cocci] [PATCH v2 1/3] media: adv748x: Delete a null pointer check in adv748x_hdmi_query_dv_timings() Markus Elfring
2023-04-18 10:04 ` [cocci] [PATCH v2 2/3] media: adv748x: Move a variable assignment behind condition checks " Markus Elfring
2023-04-18 10:06 ` [cocci] [PATCH v2 3/3] media: adv748x: Improve a size determination " Markus Elfring
2023-04-14 16:30 ` [cocci] [PATCH] media: adv7604: Move a variable assignment behind condition checks in adv76xx_query_dv_timings() Markus Elfring
2023-04-18 17:42 ` [cocci] [PATCH v2 0/4] media: adv7604: Adjustments for two function implementations Markus Elfring
2023-04-18 17:43 ` [cocci] [PATCH v2 1/4] media: adv7604: Delete a null pointer check in adv76xx_query_dv_timings() Markus Elfring
2023-04-18 17:45 ` [cocci] [PATCH v2 2/4] media: adv7604: Move a variable assignment behind condition checks " Markus Elfring
2023-04-18 17:46 ` [cocci] [PATCH v2 3/4] media: adv7604: Improve three size determinations Markus Elfring
2023-04-18 17:48 ` [cocci] [PATCH v2 4/4] media: adv7604: Reduce scope for the variable “info” in adv76xx_query_dv_timings() Markus Elfring
2023-04-14 18:30 ` [cocci] [PATCH] media: mediatek: vcodec: Move a variable assignment behind condition checks in vdec_vp9_slice_single_decode() Markus Elfring
[not found] ` <0341924c-7f0a-28aa-eeae-f7de69ab36d8@xs4all.nl>
2023-04-17 12:40 ` [cocci] [PATCH 0/2] media: mediatek: vcodec: Adjustments for vdec_vp9_slice_single_decode() Markus Elfring
2023-04-17 12:41 ` [cocci] [PATCH 1/2] media: mediatek: vcodec: Delete null pointer checks in vdec_vp9_slice_single_decode() Markus Elfring
2023-04-17 12:44 ` [cocci] [PATCH 2/2] media: mediatek: vcodec: Move variable assignments behind " Markus Elfring
2023-04-14 19:10 ` [cocci] [PATCH] media: au0828: Move a variable assignment behind condition checks in au0828_isoc_copy() Markus Elfring
[not found] ` <8153cc88-2cea-0528-9d54-bda72cbaac5b@xs4all.nl>
2023-04-17 17:00 ` [cocci] [PATCH 0/5] media: au0828: Adjustments for four function implementations Markus Elfring
2023-04-17 17:01 ` [cocci] [PATCH 1/5] media: au0828: Delete a null pointer check in au0828_isoc_copy() Markus Elfring
2023-04-17 17:02 ` [cocci] [PATCH 2/5] media: au0828: Move variable assignments behind condition checks " Markus Elfring
2023-04-17 17:05 ` [cocci] [PATCH 3/5] media: au0828: Return a status code only as a constant " Markus Elfring
2023-04-17 17:06 ` [cocci] [PATCH 4/5] media: au0828: Delete an unnecessary return statement in two functions Markus Elfring
2023-04-17 17:09 ` [cocci] [PATCH 5/5] media: au0828: Use common error handling code in au0828_init_isoc() Markus Elfring
2023-04-16 9:30 ` [cocci] [PATCH 0/9] GPU-DRM-nouveau: Adjustments for seven function implementations Markus Elfring
2023-04-16 9:33 ` [cocci] [PATCH 1/9] drm/nouveau/debugfs: Move an expression into a function call parameter in nouveau_debugfs_pstate_set() Markus Elfring
2023-04-16 9:36 ` [cocci] [PATCH 2/9] drm/nouveau/debugfs: Move a variable assignment behind a null pointer check in nouveau_debugfs_pstate_get() Markus Elfring
2023-04-16 9:38 ` [cocci] [PATCH 3/9] drm/nouveau/debugfs: Use seq_putc() " Markus Elfring
2023-04-16 9:40 ` [cocci] [PATCH 4/9] drm/nouveau/debugfs: Replace five seq_printf() calls by seq_puts() " Markus Elfring
2023-04-16 9:42 ` [cocci] [PATCH 5/9] drm/nouveau/bios/power_budget: Move an expression into a macro call parameter in nvbios_power_budget_header() Markus Elfring
2023-04-16 9:44 ` [cocci] [PATCH 6/9] drm/nouveau/clk: Move a variable assignment behind a null pointer check in nvkm_pstate_new() Markus Elfring
2023-04-16 9:46 ` [cocci] [PATCH 7/9] drm/nouveau/pci: Move a variable assignment behind condition checks in nvkm_pcie_set_link() Markus Elfring
2023-04-16 9:54 ` [cocci] [PATCH 8/9] drm/nouveau/pci: Move an expression into a function call parameter " Markus Elfring
2023-04-16 9:56 ` [cocci] [PATCH 9/9] drm/nouveau/therm: Move an assignment statement behind a null pointer check in two functions Markus Elfring
2023-04-16 15:47 ` [cocci] [PATCH] drm/bridge: it6505: Move a variable assignment behind a null pointer check in receive_timing_debugfs_show() Markus Elfring
[not found] ` <CAN6tsi7caOQZLLvbL7phMEtNvBLaWgJuHLkLo3YWdqQw7Vxnaw@mail.gmail.com>
2023-04-25 14:15 ` [cocci] " Markus Elfring
[not found] ` <CAN6tsi4WBDOyzvXJ8vV=xJYay1JbBGo+UzZ+vudTBm5Fk5nB=A@mail.gmail.com>
2023-04-27 19:34 ` Markus Elfring
[not found] ` <CAN6tsi7263VnTba+WUUWR171Y+CsOKAb=it8cofPQGRk26K=aA@mail.gmail.com>
2023-04-28 15:55 ` [cocci] [PATCH resent] " Markus Elfring
2023-04-17 9:42 ` [cocci] [PATCH] drm/mm: Adjust input parameter validation in DECLARE_NEXT_HOLE_ADDR() Markus Elfring
2023-04-19 16:48 ` [cocci] [PATCH] iwlegacy: Adjust input parameter validation in il_set_ht_add_station() Markus Elfring
2023-04-19 17:30 ` [cocci] [PATCH] iwlwifi: Adjust input parameter validation in iwl_sta_calc_ht_flags() Markus Elfring
2023-04-19 18:12 ` [cocci] [PATCH] usb: dwc2: gadget: Move a variable assignment behind condition checks in dwc2_hsotg_handle_outdone() Markus Elfring
2023-04-19 18:54 ` [cocci] [PATCH] ASoC: SOF: Intel: hda-stream: Move three variable assignments behind condition checks in hda_dsp_iccmax_stream_hw_params() Markus Elfring
[not found] ` <fbdee94e-b731-0471-e18f-b334ab0db7f5@linux.intel.com>
2023-04-24 14:56 ` Markus Elfring
2023-04-20 10:54 ` [cocci] [PATCH 0/4] staging: rtl8712: Adjustments for process_link_qual() Markus Elfring
2023-04-20 10:55 ` [cocci] [PATCH 1/4] staging: rtl8712: Delete null pointer checks in process_link_qual() Markus Elfring
2023-04-20 10:57 ` [cocci] [PATCH 2/4] staging: rtl8712: Delete two variables " Markus Elfring
2023-04-20 11:00 ` [cocci] [PATCH 3/4] staging: rtl8712: Reduce scope for the variable “sqd” " Markus Elfring
2023-04-20 11:01 ` [cocci] [PATCH 4/4] staging: rtl8712: Simplify the usage of an expression " Markus Elfring
2023-04-20 14:26 ` [cocci] [PATCH 0/4] staging: rtl8723bs: Adjustments for rtw_set_802_11_bssid_list_scan() Markus Elfring
2023-04-20 14:28 ` [cocci] [PATCH 1/4] staging: rtl8723bs: Delete a null pointer check in rtw_set_802_11_bssid_list_scan() Markus Elfring
2023-04-20 14:30 ` [cocci] [PATCH 2/4] staging: rtl8723bs: Return directly after a failed initialisation " Markus Elfring
2023-04-20 14:32 ` [cocci] [PATCH 3/4] staging: rtl8723bs: Delete an unnecessary variable initialisation " Markus Elfring
2023-04-20 14:34 ` [cocci] [PATCH 4/4] staging: rtl8723bs: Move a variable assignment behind a condition check " Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54a21fea-64e3-de67-82ef-d61b90ffad05@web.de \
--to=markus.elfring@web.de \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=cocci@inria.fr \
--cc=german.gomez@arm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).