drm/i915: Fix memory leak in intel_hdcp auth
authorRadhakrishna Sripada <radhakrishna.sripada@intel.com>
Wed, 4 Apr 2018 22:59:57 +0000 (15:59 -0700)
committerJani Nikula <jani.nikula@intel.com>
Fri, 6 Apr 2018 06:57:31 +0000 (09:57 +0300)
Static code analysis tool reported memory leak in
intel_hdcp_auth_downstream. Fixing the memory leak.

v2: Rebase, move free to a cleanup label(Jani)

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Reviewed-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180404225957.7457-1-radhakrishna.sripada@intel.com
drivers/gpu/drm/i915/intel_hdcp.c

index 98a9c81e2dc1fb05dac3d64c1900849e64344cdf..2db5da550a1c1686d98e9d6c2895f1f7dbf6f0e4 100644 (file)
@@ -435,7 +435,7 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
 
        ret = shim->read_ksv_fifo(intel_dig_port, num_downstream, ksv_fifo);
        if (ret)
-               return ret;
+               goto err;
 
        /*
         * When V prime mismatches, DP Spec mandates re-read of
@@ -451,12 +451,15 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
 
        if (i == tries) {
                DRM_ERROR("V Prime validation failed.(%d)\n", ret);
-               return ret;
+               goto err;
        }
 
        DRM_DEBUG_KMS("HDCP is enabled (%d downstream devices)\n",
                      num_downstream);
-       return 0;
+       ret = 0;
+err:
+       kfree(ksv_fifo);
+       return ret;
 }
 
 /* Implements Part 1 of the HDCP authorization procedure */