From 57f93db12b756ab1a857fae7a6bf54fc4a540b9f Mon Sep 17 00:00:00 2001 From: Gandhimathi Anand Date: Tue, 14 Feb 2012 14:06:32 -0800 Subject: [PATCH] Static Analysis fixes for OTM HDMI driver This patch comprises of multiple issues found by static analysis tools. OTM_HDMI: r2897 Signed-off-by: Arun Kannan Signed-off-by: Kirill A. Shutemov --- drivers/staging/mrst/drv/otm_hdmi/os/android/android_hdmi.c | 11 +++++++---- drivers/staging/mrst/drv/otm_hdmi/pil/common/hdcp.c | 3 ++- drivers/staging/mrst/drv/otm_hdmi/pil/common/otm_hdmi.c | 7 +++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/mrst/drv/otm_hdmi/os/android/android_hdmi.c b/drivers/staging/mrst/drv/otm_hdmi/os/android/android_hdmi.c index 9fc406c..edaf656 100644 --- a/drivers/staging/mrst/drv/otm_hdmi/os/android/android_hdmi.c +++ b/drivers/staging/mrst/drv/otm_hdmi/os/android/android_hdmi.c @@ -1413,10 +1413,9 @@ void android_disable_hdmi(struct drm_device *dev) */ enum drm_connector_status android_hdmi_detect(struct drm_connector *connector) { - struct drm_device *dev = connector->dev; - struct drm_psb_private *dev_priv = - (struct drm_psb_private *)dev->dev_private; - struct android_hdmi_priv *hdmi_priv = dev_priv->hdmi_priv; + struct drm_device *dev = NULL; + struct drm_psb_private *dev_priv = NULL; + struct android_hdmi_priv *hdmi_priv = NULL; u8 data = 0; #ifndef OTM_HDMI_FIXME @@ -1428,6 +1427,10 @@ enum drm_connector_status android_hdmi_detect(struct drm_connector *connector) if (NULL == connector || NULL == adapter) return connector_status_disconnected; + dev = connector->dev; + dev_priv = (struct drm_psb_private *)dev->dev_private; + hdmi_priv = dev_priv->hdmi_priv; + /* Check if monitor is attached to HDMI connector. */ intel_scu_ipc_ioread8(MSIC_HDMI_STATUS, &data); pr_debug("%s: HPD connected data = 0x%x.\n", __func__, data); diff --git a/drivers/staging/mrst/drv/otm_hdmi/pil/common/hdcp.c b/drivers/staging/mrst/drv/otm_hdmi/pil/common/hdcp.c index eae4761..6f99bdd 100644 --- a/drivers/staging/mrst/drv/otm_hdmi/pil/common/hdcp.c +++ b/drivers/staging/mrst/drv/otm_hdmi/pil/common/hdcp.c @@ -151,6 +151,8 @@ static bool wq_send_message_delayed(int msg, return true; else pr_debug("hdcp: failed to add messge to delayed wq\n"); + + kfree(msg_data); return false; } @@ -817,7 +819,6 @@ bool otm_hdmi_hdcp_init(hdmi_context_t *hdmi_context, } hdcp_context = kmalloc(sizeof(struct hdcp_context_t), GFP_KERNEL); - hdcp_context->hdcp_wq = NULL; if (hdcp_context != NULL) hdcp_context->hdcp_wq = create_workqueue("HDCP_WQ"); diff --git a/drivers/staging/mrst/drv/otm_hdmi/pil/common/otm_hdmi.c b/drivers/staging/mrst/drv/otm_hdmi/pil/common/otm_hdmi.c index 90dc331..ce81013 100644 --- a/drivers/staging/mrst/drv/otm_hdmi/pil/common/otm_hdmi.c +++ b/drivers/staging/mrst/drv/otm_hdmi/pil/common/otm_hdmi.c @@ -940,7 +940,6 @@ otm_hdmi_ret_t otm_hdmi_device_init(void **context, struct pci_dev *pdev) otm_hdmi_ret_t rc = OTM_HDMI_SUCCESS; hdmi_context_t *ctx = NULL; int n; - int ret; PD_LOG_ENTRY(PD_LOG_LEVEL_HIGH); @@ -1748,7 +1747,7 @@ static otm_hdmi_ret_t __pd_attr_declare(otm_hdmi_attribute_t *table, return OTM_HDMI_ERR_FAILED; if ((name != NULL) && (strlen(name) < OTM_HDMI_MAX_STRING_LENGTH)) - strncpy(table[id].name, name, strlen(name)); + strncpy(table[id].name, name, strlen(table[id].name)); else if (strlen(table[id].name) == 0) PD_LOG_ERROR("set default name\n"); /* TODO: set default name */ @@ -1770,8 +1769,8 @@ static otm_hdmi_ret_t __pd_attr_declare(otm_hdmi_attribute_t *table, if ((value != NULL) && strlen(value) < OTM_HDMI_MAX_STRING_LENGTH) strncpy(table[id].content.string.value, - (char *) value, - strlen(value)); + (char *) value, + strlen(table[id].content.string.value)); else rc = OTM_HDMI_ERR_FAILED; break; -- 2.7.4