From 33827fec9d908a5ffe7cd12a542506cd8d71db4f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Aug 2022 16:38:47 +0200 Subject: [PATCH] 5.15-stable patches added patches: drm-meson-fix-refcount-leak-in-meson_encoder_hdmi_init.patch drm-msm-fix-dirtyfb-refcounting.patch tracing-perf-avoid-warray-bounds-warning-for-__rel_loc-macro.patch --- ...ount-leak-in-meson_encoder_hdmi_init.patch | 39 ++++++++++ .../drm-msm-fix-dirtyfb-refcounting.patch | 42 +++++++++++ queue-5.15/series | 3 + ...y-bounds-warning-for-__rel_loc-macro.patch | 72 +++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 queue-5.15/drm-meson-fix-refcount-leak-in-meson_encoder_hdmi_init.patch create mode 100644 queue-5.15/drm-msm-fix-dirtyfb-refcounting.patch create mode 100644 queue-5.15/tracing-perf-avoid-warray-bounds-warning-for-__rel_loc-macro.patch diff --git a/queue-5.15/drm-meson-fix-refcount-leak-in-meson_encoder_hdmi_init.patch b/queue-5.15/drm-meson-fix-refcount-leak-in-meson_encoder_hdmi_init.patch new file mode 100644 index 00000000000..718cab23efb --- /dev/null +++ b/queue-5.15/drm-meson-fix-refcount-leak-in-meson_encoder_hdmi_init.patch @@ -0,0 +1,39 @@ +From 7381076809586528e2a812a709e2758916318a99 Mon Sep 17 00:00:00 2001 +From: Miaoqian Lin +Date: Wed, 11 May 2022 09:40:51 +0400 +Subject: drm/meson: Fix refcount leak in meson_encoder_hdmi_init + +From: Miaoqian Lin + +commit 7381076809586528e2a812a709e2758916318a99 upstream. + +of_find_device_by_node() takes reference, we should use put_device() +to release it when not need anymore. +Add missing put_device() in error path to avoid refcount +leak. + +Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR") +Signed-off-by: Miaoqian Lin +Reviewed-by: Martin Blumenstingl +Reviewed-by: Neil Armstrong +Signed-off-by: Neil Armstrong +Link: https://patchwork.freedesktop.org/patch/msgid/20220511054052.51981-1-linmq006@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c ++++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c +@@ -438,8 +438,10 @@ int meson_encoder_hdmi_init(struct meson + cec_fill_conn_info_from_drm(&conn_info, meson_encoder_hdmi->connector); + + notifier = cec_notifier_conn_register(&pdev->dev, NULL, &conn_info); +- if (!notifier) ++ if (!notifier) { ++ put_device(&pdev->dev); + return -ENOMEM; ++ } + + meson_encoder_hdmi->cec_notifier = notifier; + } diff --git a/queue-5.15/drm-msm-fix-dirtyfb-refcounting.patch b/queue-5.15/drm-msm-fix-dirtyfb-refcounting.patch new file mode 100644 index 00000000000..2688eecf16c --- /dev/null +++ b/queue-5.15/drm-msm-fix-dirtyfb-refcounting.patch @@ -0,0 +1,42 @@ +From 9225b337072a10bf9b09df8bf281437488dd8a26 Mon Sep 17 00:00:00 2001 +From: Rob Clark +Date: Fri, 4 Mar 2022 12:21:45 -0800 +Subject: drm/msm: Fix dirtyfb refcounting + +From: Rob Clark + +commit 9225b337072a10bf9b09df8bf281437488dd8a26 upstream. + +refcount_t complains about 0->1 transitions, which isn't *quite* what we +wanted. So use dirtyfb==1 to mean that the fb is not connected to any +output that requires dirtyfb flushing, so that we can keep the underflow +and overflow checking. + +Fixes: 9e4dde28e9cd ("drm/msm: Avoid dirtyfb stalls on video mode displays (v2)") +Signed-off-by: Rob Clark +Link: https://lore.kernel.org/r/20220304202146.845566-1-robdclark@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/msm/msm_fb.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/msm/msm_fb.c ++++ b/drivers/gpu/drm/msm/msm_fb.c +@@ -37,7 +37,7 @@ static int msm_framebuffer_dirtyfb(struc + /* If this fb is not used on any display requiring pixel data to be + * flushed, then skip dirtyfb + */ +- if (refcount_read(&msm_fb->dirtyfb) == 0) ++ if (refcount_read(&msm_fb->dirtyfb) == 1) + return 0; + + return drm_atomic_helper_dirtyfb(fb, file_priv, flags, color, +@@ -221,6 +221,8 @@ static struct drm_framebuffer *msm_frame + goto fail; + } + ++ refcount_set(&msm_fb->dirtyfb, 1); ++ + drm_dbg_state(dev, "create: FB ID: %d (%p)", fb->base.id, fb); + + return fb; diff --git a/queue-5.15/series b/queue-5.15/series index 54ebd315fbd..88d3a1001f3 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -769,3 +769,6 @@ revert-s390-smp-enforce-lowcore-protection-on-cpu-restart.patch drm-bridge-tc358767-fix-e-dp-bridge-endpoint-parsing-in-dedicated-function.patch net-phy-smsc-disable-energy-detect-power-down-in-interrupt-mode.patch drm-vc4-change-vc4_dma_range_matches-from-a-global-to-static.patch +tracing-perf-avoid-warray-bounds-warning-for-__rel_loc-macro.patch +drm-msm-fix-dirtyfb-refcounting.patch +drm-meson-fix-refcount-leak-in-meson_encoder_hdmi_init.patch diff --git a/queue-5.15/tracing-perf-avoid-warray-bounds-warning-for-__rel_loc-macro.patch b/queue-5.15/tracing-perf-avoid-warray-bounds-warning-for-__rel_loc-macro.patch new file mode 100644 index 00000000000..7c016f345d7 --- /dev/null +++ b/queue-5.15/tracing-perf-avoid-warray-bounds-warning-for-__rel_loc-macro.patch @@ -0,0 +1,72 @@ +From c6d777acdf8f62d4ebaef0e5c6cd8fedbd6e8546 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Tue, 25 Jan 2022 14:00:37 -0800 +Subject: tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro + +From: Kees Cook + +commit c6d777acdf8f62d4ebaef0e5c6cd8fedbd6e8546 upstream. + +As done for trace_events.h, also fix the __rel_loc macro in perf.h, +which silences the -Warray-bounds warning: + +In file included from ./include/linux/string.h:253, + from ./include/linux/bitmap.h:11, + from ./include/linux/cpumask.h:12, + from ./include/linux/mm_types_task.h:14, + from ./include/linux/mm_types.h:5, + from ./include/linux/buildid.h:5, + from ./include/linux/module.h:14, + from samples/trace_events/trace-events-sample.c:2: +In function '__fortify_strcpy', + inlined from 'perf_trace_foo_rel_loc' at samples/trace_events/./trace-events-sample.h:519:1: +./include/linux/fortify-string.h:47:33: warning: '__builtin_strcpy' offset 12 is out of the bounds [ +0, 4] [-Warray-bounds] + 47 | #define __underlying_strcpy __builtin_strcpy + | ^ +./include/linux/fortify-string.h:445:24: note: in expansion of macro '__underlying_strcpy' + 445 | return __underlying_strcpy(p, q); + | ^~~~~~~~~~~~~~~~~~~ + +Also make __data struct member a proper flexible array to avoid future +problems. + +Link: https://lkml.kernel.org/r/20220125220037.2738923-1-keescook@chromium.org + +Cc: Steven Rostedt +Cc: Masami Hiramatsu +Fixes: 55de2c0b5610c ("tracing: Add '__rel_loc' using trace event macros") +Reported-by: Stephen Rothwell +Signed-off-by: Kees Cook +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + include/trace/perf.h | 5 +++-- + include/trace/trace_events.h | 2 +- + 2 files changed, 4 insertions(+), 3 deletions(-) + +--- a/include/trace/perf.h ++++ b/include/trace/perf.h +@@ -23,8 +23,9 @@ + + #undef __get_rel_dynamic_array + #define __get_rel_dynamic_array(field) \ +- ((void *)(&__entry->__rel_loc_##field) + \ +- sizeof(__entry->__rel_loc_##field) + \ ++ ((void *)__entry + \ ++ offsetof(typeof(*__entry), __rel_loc_##field) + \ ++ sizeof(__entry->__rel_loc_##field) + \ + (__entry->__rel_loc_##field & 0xffff)) + + #undef __get_rel_dynamic_array_len +--- a/include/trace/trace_events.h ++++ b/include/trace/trace_events.h +@@ -128,7 +128,7 @@ TRACE_MAKE_SYSTEM_STR(); + struct trace_event_raw_##name { \ + struct trace_entry ent; \ + tstruct \ +- char __data[0]; \ ++ char __data[]; \ + }; \ + \ + static struct trace_event_class event_class_##name; -- 2.47.3