[Intel-gfx] [PATCH v2] drm/dp: Make space for null terminator in the DP device ID char array

Pandiyan, Dhinakaran dhinakaran.pandiyan at intel.com
Tue Nov 15 00:04:23 UTC 2016


Adding Cc's.


On Mon, 2016-11-07 at 15:22 -0800, Dhinakaran Pandiyan wrote:
> The DP device identification string read from the DPCD registers is 6
> characters long at max. and we store it in a char array of the same length
> without space for the NULL terminator. Fix this by increasing the array
> size to 7 and initialize it to an empty string.
> 
> v2: Use %*pE format specifier (Jani)
> 
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 3e6fe82..2d42760 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -544,7 +544,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
>  				 DP_DETAILED_CAP_INFO_AVAILABLE;
>  	int clk;
>  	int bpc;
> -	char id[6];
> +	char id[6] = "";
>  	int len;
>  	uint8_t rev[2];
>  	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
> @@ -584,7 +584,8 @@ void drm_dp_downstream_debug(struct seq_file *m,
>  	}
>  
>  	drm_dp_downstream_id(aux, id);
> -	seq_printf(m, "\t\tID: %s\n", id);
> +	len = strnlen(id, 6);
> +	seq_printf(m, "\t\tID: %*pE\n", len, id);
>  
>  	len = drm_dp_dpcd_read(aux, DP_BRANCH_HW_REV, &rev[0], 1);
>  	if (len > 0)



More information about the dri-devel mailing list