Patch "drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-i915-tc-fix-wformat-truncation-in-intel_tc_port_.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 573d32dc746063da10c32fab1409746344ffba22
Author: Nirmoy Das <nirmoy.das@xxxxxxxxx>
Date:   Thu Oct 26 14:56:36 2023 +0200

    drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init
    
    [ Upstream commit 9506fba463fcbdf8c8b7af3ec9ee34360df843fe ]
    
    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)
    v3: use const for port_name, and fix tc mem leak(Imre)
    
    Fixes: 3eafcddf766b ("drm/i915/tc: Move TC port fields to a new intel_tc_port struct")
    Cc: Mika Kahola <mika.kahola@xxxxxxxxx>
    Cc: Imre Deak <imre.deak@xxxxxxxxx>
    Cc: Jani Nikula <jani.nikula@xxxxxxxxx>
    Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxxxx>
    Reviewed-by: Andrzej Hajda <andrzej.hajda@xxxxxxxxx>
    Reviewed-by: Imre Deak <imre.deak@xxxxxxxxx>
    Reviewed-by: Mika Kahola <mika.kahola@xxxxxxxxx>
    Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20231026125636.5080-1-nirmoy.das@xxxxxxxxx
    (cherry picked from commit 70a3cbbe620ee66afb0c066624196077767e61b2)
    Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
index 3ebf41859043e..cdf2455440bea 100644
--- a/drivers/gpu/drm/i915/display/intel_tc.c
+++ b/drivers/gpu/drm/i915/display/intel_tc.c
@@ -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];
+	const char *port_name;
 	enum tc_port_mode mode;
 	enum tc_port_mode init_mode;
 	enum phy_fia phy_fia;
@@ -1841,8 +1841,12 @@ 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) {
+		kfree(tc);
+		return -ENOMEM;
+	}
 
 	mutex_init(&tc->lock);
 	/* TODO: Combine the two works */
@@ -1863,6 +1867,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;
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux