diff mbox

drm/dp: Make space for null terminator in the DP device ID char array

Message ID 1478293580-7817-1-git-send-email-dhinakaran.pandiyan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dhinakaran Pandiyan Nov. 4, 2016, 9:06 p.m. UTC
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.

Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 drivers/gpu/drm/drm_dp_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dhinakaran Pandiyan Nov. 7, 2016, 6:59 p.m. UTC | #1
Mika,

Can you take a look at this?

-DK

On Fri, 2016-11-04 at 14:06 -0700, 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.

> 

> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>

> ---

>  drivers/gpu/drm/drm_dp_helper.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c

> index 3e6fe82..3a39312 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[7] = "";

>  	int len;

>  	uint8_t rev[2];

>  	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
Jani Nikula Nov. 7, 2016, 7:16 p.m. UTC | #2
On Fri, 04 Nov 2016, Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> 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.
>
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 3e6fe82..3a39312 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[7] = "";

Or use %*pE in the format string and provide the length.

BR,
Jani.

>  	int len;
>  	uint8_t rev[2];
>  	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 3e6fe82..3a39312 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[7] = "";
 	int len;
 	uint8_t rev[2];
 	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;