summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoj Rao <manojraj@codeaurora.org>2013-08-12 23:37:18 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:20:09 -0700
commit4a13122516e0823062df2ebc7ea37f6176dbe49e (patch)
tree7c9804a7aebf12a1294e8857686e4fb505a175c0
parentd71d856bf93be6c31a03f1d3f7fa954a5b52ddb4 (diff)
msm: mdss: hdmi: NUL-terminate spd data
NUL-terminate SPD Vendor name and SPD Product description data stored in the control structure of hdmi driver. This avoids overflows in print messages and info frames. Change-Id: I0a0adcfad06625e4d7368d3c5cd0ec38f0e047d8 CRs-Fixed: 520148 Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
-rw-r--r--drivers/video/fbdev/msm/mdss_hdmi_tx.c12
-rw-r--r--drivers/video/fbdev/msm/mdss_hdmi_tx.h4
2 files changed, 10 insertions, 6 deletions
diff --git a/drivers/video/fbdev/msm/mdss_hdmi_tx.c b/drivers/video/fbdev/msm/mdss_hdmi_tx.c
index 615d1d8373e6..8dbe735a7d00 100644
--- a/drivers/video/fbdev/msm/mdss_hdmi_tx.c
+++ b/drivers/video/fbdev/msm/mdss_hdmi_tx.c
@@ -493,7 +493,7 @@ static ssize_t hdmi_tx_sysfs_wta_hpd(struct device *dev,
static ssize_t hdmi_tx_sysfs_wta_vendor_name(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- ssize_t ret;
+ ssize_t ret, sz;
u8 *s = (u8 *) buf;
u8 *d = NULL;
struct hdmi_tx_ctrl *hdmi_ctrl =
@@ -508,7 +508,8 @@ static ssize_t hdmi_tx_sysfs_wta_vendor_name(struct device *dev,
ret = strnlen(buf, PAGE_SIZE);
ret = (ret > 8) ? 8 : ret;
- memset(hdmi_ctrl->spd_vendor_name, 0, 8);
+ sz = sizeof(hdmi_ctrl->spd_vendor_name);
+ memset(hdmi_ctrl->spd_vendor_name, 0, sz);
while (*s) {
if (*s & 0x60 && *s ^ 0x7f) {
*d = *s;
@@ -522,6 +523,7 @@ static ssize_t hdmi_tx_sysfs_wta_vendor_name(struct device *dev,
d++;
}
+ hdmi_ctrl->spd_vendor_name[sz - 1] = 0;
DEV_DBG("%s: '%s'\n", __func__, hdmi_ctrl->spd_vendor_name);
@@ -549,7 +551,7 @@ static ssize_t hdmi_tx_sysfs_rda_vendor_name(struct device *dev,
static ssize_t hdmi_tx_sysfs_wta_product_description(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- ssize_t ret;
+ ssize_t ret, sz;
u8 *s = (u8 *) buf;
u8 *d = NULL;
struct hdmi_tx_ctrl *hdmi_ctrl =
@@ -564,7 +566,8 @@ static ssize_t hdmi_tx_sysfs_wta_product_description(struct device *dev,
ret = strnlen(buf, PAGE_SIZE);
ret = (ret > 16) ? 16 : ret;
- memset(hdmi_ctrl->spd_product_description, 0, 16);
+ sz = sizeof(hdmi_ctrl->spd_product_description);
+ memset(hdmi_ctrl->spd_product_description, 0, sz);
while (*s) {
if (*s & 0x60 && *s ^ 0x7f) {
*d = *s;
@@ -578,6 +581,7 @@ static ssize_t hdmi_tx_sysfs_wta_product_description(struct device *dev,
d++;
}
+ hdmi_ctrl->spd_product_description[sz - 1] = 0;
DEV_DBG("%s: '%s'\n", __func__, hdmi_ctrl->spd_product_description);
diff --git a/drivers/video/fbdev/msm/mdss_hdmi_tx.h b/drivers/video/fbdev/msm/mdss_hdmi_tx.h
index 18ee782d916a..fd955824a2b2 100644
--- a/drivers/video/fbdev/msm/mdss_hdmi_tx.h
+++ b/drivers/video/fbdev/msm/mdss_hdmi_tx.h
@@ -79,8 +79,8 @@ struct hdmi_tx_ctrl {
bool hdcp_feature_on;
u32 present_hdcp;
- u8 spd_vendor_name[8];
- u8 spd_product_description[16];
+ u8 spd_vendor_name[9];
+ u8 spd_product_description[17];
struct hdmi_tx_ddc_ctrl ddc_ctrl;