Skip to contentSkip to conversation

drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init

PATCH Superseded Nirmoy Das 5 participants 6 messages Oct 25, 2023 – Oct 26, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH v2 1/1 drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init

Fix below compiler warning:

intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]

"%c/TC#%d", port_name(port), tc_port + 1);
           ^~

intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes into a destination of size 8
snprintf(tc->port_name, sizeof(tc->port_name), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    "%c/TC#%d", port_name(port), tc_port + 1);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

v2: use kasprintf(Imre)

Fixes 3eafcddf766b ("drm/i915/tc: Move TC port fields to a new intel_tc_port struct")
Cc Mika Kahola <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_tc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_tc.c +6 -3
index 37b0f8529b4f..0fa54450d51b 100644
@@ -58,7 +58,7 @@ struct intel_tc_port {
 	struct delayed_work link_reset_work;
 	int link_refcount;
 	bool legacy_port:1;
-	char port_name[8];
+	char *port_name;
 	enum tc_port_mode mode;
 	enum tc_port_mode init_mode;
 	enum phy_fia phy_fia;
@@ -1875,8 +1875,10 @@ int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
 	else
 		tc->phy_ops = &icl_tc_phy_ops;
 
-	snprintf(tc->port_name, sizeof(tc->port_name),
-		 "%c/TC#%d", port_name(port), tc_port + 1);
+	tc->port_name = kasprintf(GFP_KERNEL, "%c/TC#%d", port_name(port),
+				  tc_port + 1);
+	if (!tc->port_name)
+		return -ENOMEM;
 
 	mutex_init(&tc->lock);
 	/* TODO: Combine the two works */
@@ -1897,6 +1899,7 @@ void intel_tc_port_cleanup(struct intel_digital_port *dig_port)
 {
 	intel_tc_port_suspend(dig_port);
 
+	kfree(dig_port->tc->port_name);
 	kfree(dig_port->tc);
 	dig_port->tc = NULL;
 }
Signature · 1 line
2.41.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 14 lines · Nirmoy Das

Fix below compiler warning:

intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]

"%c/TC#%d", port_name(port), tc_port + 1);
            ^~

intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes into a destination of size 8
snprintf(tc->port_name, sizeof(tc->port_name), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     "%c/TC#%d", port_name(port), tc_port + 1);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

v2: use kasprintf(Imre)

Fixes 3eafcddf766b ("drm/i915/tc: Move TC port fields to a new intel_tc_port struct")
Cc Mika Kahola <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>

Regards
Andrzej

Quoted 38 lines
---
  drivers/gpu/drm/i915/display/intel_tc.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_tc.c +6 -3
index 37b0f8529b4f..0fa54450d51b 100644
@@ -58,7 +58,7 @@ struct intel_tc_port {
  	struct delayed_work link_reset_work;
  	int link_refcount;
  	bool legacy_port:1;
-	char port_name[8];
+	char *port_name;
  	enum tc_port_mode mode;
  	enum tc_port_mode init_mode;
  	enum phy_fia phy_fia;
@@ -1875,8 +1875,10 @@ int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
  	else
  		tc->phy_ops = &icl_tc_phy_ops;
 
-	snprintf(tc->port_name, sizeof(tc->port_name),
-		 "%c/TC#%d", port_name(port), tc_port + 1);
+	tc->port_name = kasprintf(GFP_KERNEL, "%c/TC#%d", port_name(port),
+				  tc_port + 1);
+	if (!tc->port_name)
+		return -ENOMEM;
 
  	mutex_init(&tc->lock);
  	/* TODO: Combine the two works */
@@ -1897,6 +1899,7 @@ void intel_tc_port_cleanup(struct intel_digital_port *dig_port)
  {
  	intel_tc_port_suspend(dig_port);
 
+	kfree(dig_port->tc->port_name);
  	kfree(dig_port->tc);
  	dig_port->tc = NULL;
  }
#2 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init (rev2)

In reply to Nirmoy Das
== Series Details ==

== Series Details ==

Series: drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init (rev2)
URL : https://patchwork.freedesktop.org/series/125576/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13786 -> Patchwork_125576v2
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_125576v2 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_125576v2, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/index.html

Participating hosts (38 -> 38)
------------------------------

Additional (3): fi-kbl-soraka bat-adlp-11 bat-dg1-5
Missing (3): fi-bsw-n3050 fi-snb-2520m fi-pnv-d510

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_125576v2:

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_suspend@basic-s3@smem:
- fi-skl-guc: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13786/fi-skl-guc/igt@gem_exec_suspend@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/fi-skl-guc/igt@gem_exec_suspend@[email protected]

Known issues
------------

Here are the changes found in Patchwork_125576v2 that come from known issues:

### CI changes ###

#### Possible fixes ####

* boot:
- bat-jsl-1: [FAIL][3] ([i915#8293]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13786/bat-jsl-1/boot.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/boot.html

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- bat-adlp-11: NOTRUN -> [SKIP][5] ([i915#9318])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-adlp-11/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][6] ([i915#9318])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/igt@[email protected]

* igt@gem_exec_suspend@basic-s0@lmem0:
- bat-dg2-9: [PASS][7] -> [INCOMPLETE][8] ([i915#9275])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13786/bat-dg2-9/igt@gem_exec_suspend@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg2-9/igt@gem_exec_suspend@[email protected]

* igt@gem_huc_copy@huc-copy:
- bat-jsl-1: NOTRUN -> [SKIP][9] ([i915#2190])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/igt@[email protected]
- fi-kbl-soraka: NOTRUN -> [SKIP][10] ([fdo#109271] / [i915#2190])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][11] ([fdo#109271] / [i915#4613]) +3 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@verify-random:
- bat-jsl-1: NOTRUN -> [SKIP][12] ([i915#4613]) +3 other tests skip
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/igt@[email protected]

* igt@gem_mmap@basic:
- bat-dg1-5: NOTRUN -> [SKIP][13] ([i915#4083])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@gem_tiled_fence_blits@basic:
- bat-dg1-5: NOTRUN -> [SKIP][14] ([i915#4077]) +2 other tests skip
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@gem_tiled_pread_basic:
- bat-dg1-5: NOTRUN -> [SKIP][15] ([i915#4079]) +1 other test skip
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@gem_tiled_pread_basic.html
- bat-adlp-11: NOTRUN -> [SKIP][16] ([i915#3282])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-adlp-11/igt@gem_tiled_pread_basic.html

* igt@i915_pm_rps@basic-api:
- bat-dg1-5: NOTRUN -> [SKIP][17] ([i915#6621])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][18] ([i915#5334] / [i915#7872])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_selftest@live@gt_pm:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][19] ([i915#1886])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

* igt@kms_addfb_basic@basic-x-tiled-legacy:
- bat-dg1-5: NOTRUN -> [SKIP][20] ([i915#4212]) +7 other tests skip
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-dg1-5: NOTRUN -> [SKIP][21] ([i915#4215])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-adlp-11: NOTRUN -> [SKIP][22] ([i915#4103] / [i915#5608]) +1 other test skip
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-adlp-11/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][23] ([i915#4103]) +1 other test skip
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/igt@[email protected]
- bat-dg1-5: NOTRUN -> [SKIP][24] ([i915#4103] / [i915#4213]) +1 other test skip
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][25] ([fdo#109271]) +9 other tests skip
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/fi-kbl-soraka/igt@[email protected]
- bat-adlp-11: NOTRUN -> [SKIP][26] ([i915#3555] / [i915#3840])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-adlp-11/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][27] ([i915#3555]) +1 other test skip
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/igt@[email protected]
- bat-dg1-5: NOTRUN -> [SKIP][28] ([i915#3555] / [i915#3840])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-jsl-1: NOTRUN -> [SKIP][29] ([fdo#109285])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-jsl-1/igt@[email protected]
- bat-dg1-5: NOTRUN -> [SKIP][30] ([fdo#109285])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-adlp-11: NOTRUN -> [SKIP][31] ([i915#4093]) +3 other tests skip
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-adlp-11/igt@[email protected]

* igt@kms_hdmi_inject@inject-audio:
- bat-dg1-5: NOTRUN -> [SKIP][32] ([i915#433])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]
- bat-adlp-11: NOTRUN -> [SKIP][33] ([i915#4369])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-adlp-11/igt@[email protected]

* igt@kms_psr@sprite_plane_onoff:
- bat-dg1-5: NOTRUN -> [SKIP][34] ([i915#1072] / [i915#4078]) +3 other tests skip
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@kms_psr@sprite_plane_onoff.html

* igt@kms_setmode@basic-clone-single-crtc:
- bat-dg1-5: NOTRUN -> [SKIP][35] ([i915#3555])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@prime_vgem@basic-fence-read:
- bat-dg1-5: NOTRUN -> [SKIP][36] ([i915#3708]) +3 other tests skip
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

* igt@prime_vgem@basic-gtt:
- bat-dg1-5: NOTRUN -> [SKIP][37] ([i915#3708] / [i915#4077]) +1 other test skip
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/bat-dg1-5/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4093]: https://gitlab.freedesktop.org/drm/intel/issues/4093
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#433]: https://gitlab.freedesktop.org/drm/intel/issues/433
[i915#4369]: https://gitlab.freedesktop.org/drm/intel/issues/4369
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5608]: https://gitlab.freedesktop.org/drm/intel/issues/5608
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#7872]: https://gitlab.freedesktop.org/drm/intel/issues/7872
[i915#8293]: https://gitlab.freedesktop.org/drm/intel/issues/8293
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#9275]: https://gitlab.freedesktop.org/drm/intel/issues/9275
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318

Build changes
-------------

* Linux: CI_DRM_13786 -> Patchwork_125576v2

CI-20190529: 20190529
CI_DRM_13786: e8d777a5e7e0ec452142ad0073022733f99c1eb7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7557: 18fc864d68d382847596594d7eb3488f2c8fb45e @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_125576v2: e8d777a5e7e0ec452142ad0073022733f99c1eb7 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

fb311f97922c drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_125576v2/index.html

Reviewed-by on v2 1/1
#3 lore raw
In reply to Nirmoy Das
Quoted 14 lines · Nirmoy Das

Fix below compiler warning:

intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]

"%c/TC#%d", port_name(port), tc_port + 1);
           ^~

intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes into a destination of size 8
snprintf(tc->port_name, sizeof(tc->port_name), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    "%c/TC#%d", port_name(port), tc_port + 1);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

v2: use kasprintf(Imre)

Fixes 3eafcddf766b ("drm/i915/tc: Move TC port fields to a new intel_tc_port struct")
Cc Mika Kahola <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>

Nit: port_name could be const.

Quoted 41 lines
---
 drivers/gpu/drm/i915/display/intel_tc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_tc.c +6 -3
index 37b0f8529b4f..0fa54450d51b 100644
@@ -58,7 +58,7 @@ struct intel_tc_port {
 	struct delayed_work link_reset_work;
 	int link_refcount;
 	bool legacy_port:1;
-	char port_name[8];
+	char *port_name;
 	enum tc_port_mode mode;
 	enum tc_port_mode init_mode;
 	enum phy_fia phy_fia;
@@ -1875,8 +1875,10 @@ int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
 	else
 		tc->phy_ops = &icl_tc_phy_ops;
 
-	snprintf(tc->port_name, sizeof(tc->port_name),
-		 "%c/TC#%d", port_name(port), tc_port + 1);
+	tc->port_name = kasprintf(GFP_KERNEL, "%c/TC#%d", port_name(port),
+				  tc_port + 1);
+	if (!tc->port_name)
+		return -ENOMEM;
 
 	mutex_init(&tc->lock);
 	/* TODO: Combine the two works */
@@ -1897,6 +1899,7 @@ void intel_tc_port_cleanup(struct intel_digital_port *dig_port)
 {
 	intel_tc_port_suspend(dig_port);
 
+	kfree(dig_port->tc->port_name);
 	kfree(dig_port->tc);
 	dig_port->tc = NULL;
 }
Signature · 1 line
2.41.0
#4 lore raw
Quoted 48 lines · Imre Deak
Quoted 14 lines · Nirmoy Das

Fix below compiler warning:

intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]

"%c/TC#%d", port_name(port), tc_port + 1);
           ^~

intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes into a destination of size 8
snprintf(tc->port_name, sizeof(tc->port_name), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    "%c/TC#%d", port_name(port), tc_port + 1);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

v2: use kasprintf(Imre)

Fixes 3eafcddf766b ("drm/i915/tc: Move TC port fields to a new intel_tc_port struct")
Cc Mika Kahola <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>

Nit: port_name could be const.

Quoted 21 lines
---
 drivers/gpu/drm/i915/display/intel_tc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_tc.c +1 -1
index 37b0f8529b4f..0fa54450d51b 100644
@@ -58,7 +58,7 @@ struct intel_tc_port {
 	struct delayed_work link_reset_work;
 	int link_refcount;
 	bool legacy_port:1;
-	char port_name[8];
+	char *port_name;
 	enum tc_port_mode mode;
 	enum tc_port_mode init_mode;
 	enum phy_fia phy_fia;
@@ -1875,8 +1875,10 @@ int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
 	else
 		tc->phy_ops = &icl_tc_phy_ops;
 
Quoted 6 lines

drivers/gpu/drm/i915/display/intel_tc.c int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy) · line 1881

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_tc.c +4 -2
-	snprintf(tc->port_name, sizeof(tc->port_name),
-		 "%c/TC#%d", port_name(port), tc_port + 1);
+	tc->port_name = kasprintf(GFP_KERNEL, "%c/TC#%d", port_name(port),
+				  tc_port + 1);
+	if (!tc->port_name)
+		return -ENOMEM;

Missed it, but this needs to free tc;

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/i915/display/intel_tc.c +1 -0
 	mutex_init(&tc->lock);
 	/* TODO: Combine the two works */
@@ -1897,6 +1899,7 @@ void intel_tc_port_cleanup(struct intel_digital_port *dig_port)
 {
 	intel_tc_port_suspend(dig_port);
 
+	kfree(dig_port->tc->port_name);
 	kfree(dig_port->tc);
 	dig_port->tc = NULL;
 }
Signature · 1 line
2.41.0
#5 lore raw
Quoted 48 lines · Imre Deak
Quoted 47 lines · Imre Deak
Quoted 14 lines · Nirmoy Das

Fix below compiler warning:

intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]

"%c/TC#%d", port_name(port), tc_port + 1);
            ^~

intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes into a destination of size 8
snprintf(tc->port_name, sizeof(tc->port_name), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     "%c/TC#%d", port_name(port), tc_port + 1);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

v2: use kasprintf(Imre)

Fixes 3eafcddf766b ("drm/i915/tc: Move TC port fields to a new intel_tc_port struct")
Cc Mika Kahola <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>

Nit: port_name could be const.

Quoted 21 lines
---
  drivers/gpu/drm/i915/display/intel_tc.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_tc.c +1 -1
index 37b0f8529b4f..0fa54450d51b 100644
@@ -58,7 +58,7 @@ struct intel_tc_port {
  	struct delayed_work link_reset_work;
  	int link_refcount;
  	bool legacy_port:1;
-	char port_name[8];
+	char *port_name;
  	enum tc_port_mode mode;
  	enum tc_port_mode init_mode;
  	enum phy_fia phy_fia;
@@ -1875,8 +1875,10 @@ int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
  	else
  		tc->phy_ops = &icl_tc_phy_ops;
 
Quoted 7 lines
Quoted 6 lines

drivers/gpu/drm/i915/display/intel_tc.c int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy) · line 1881

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_tc.c +4 -2
-	snprintf(tc->port_name, sizeof(tc->port_name),
-		 "%c/TC#%d", port_name(port), tc_port + 1);
+	tc->port_name = kasprintf(GFP_KERNEL, "%c/TC#%d", port_name(port),
+				  tc_port + 1);
+	if (!tc->port_name)
+		return -ENOMEM;

Missed it, but this needs to free tc;

Oh, thanks for catching it.

Regards,

Nirmoy

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_tc.c +1 -0
  	mutex_init(&tc->lock);
  	/* TODO: Combine the two works */
@@ -1897,6 +1899,7 @@ void intel_tc_port_cleanup(struct intel_digital_port *dig_port)
  {
  	intel_tc_port_suspend(dig_port);
 
+	kfree(dig_port->tc->port_name);
  	kfree(dig_port->tc);
  	dig_port->tc = NULL;
  }
Signature · 1 line
2.41.0