diff mbox

[v2] drm/i915: Fix memory leak in intel_hdcp auth

Message ID 20180404225957.7457-1-radhakrishna.sripada@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sripada, Radhakrishna April 4, 2018, 10:59 p.m. UTC
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>
---
 drivers/gpu/drm/i915/intel_hdcp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Srivatsa, Anusha April 5, 2018, 6:31 a.m. UTC | #1
Earlier, I responded to the wrong version of the patch :(
Apologies.

>-----Original Message-----
>From: Sripada, Radhakrishna
>Sent: Wednesday, April 4, 2018 4:00 PM
>To: intel-gfx@lists.freedesktop.org
>Cc: Sripada, Radhakrishna <radhakrishna.sripada@intel.com>; Jani Nikula
><jani.nikula@linux.intel.com>; Srivatsa, Anusha <anusha.srivatsa@intel.com>
>Subject: [PATCH v2] drm/i915: Fix memory leak in intel_hdcp auth
>
>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>

>---
> drivers/gpu/drm/i915/intel_hdcp.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/intel_hdcp.c
>b/drivers/gpu/drm/i915/intel_hdcp.c
>index 98a9c81e2dc1..2db5da550a1c 100644
>--- a/drivers/gpu/drm/i915/intel_hdcp.c
>+++ b/drivers/gpu/drm/i915/intel_hdcp.c
>@@ -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 */
>--
>2.9.3
Jani Nikula April 6, 2018, 7:07 a.m. UTC | #2
On Thu, 05 Apr 2018, "Srivatsa, Anusha" <anusha.srivatsa@intel.com> wrote:
> Earlier, I responded to the wrong version of the patch :(
> Apologies.
>
>>-----Original Message-----
>>From: Sripada, Radhakrishna
>>Sent: Wednesday, April 4, 2018 4:00 PM
>>To: intel-gfx@lists.freedesktop.org
>>Cc: Sripada, Radhakrishna <radhakrishna.sripada@intel.com>; Jani Nikula
>><jani.nikula@linux.intel.com>; Srivatsa, Anusha <anusha.srivatsa@intel.com>
>>Subject: [PATCH v2] drm/i915: Fix memory leak in intel_hdcp auth
>>
>>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>

Thanks for the patch and the review, pushed to dinq.

BR,
Jani.

>
>>---
>> drivers/gpu/drm/i915/intel_hdcp.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>>diff --git a/drivers/gpu/drm/i915/intel_hdcp.c
>>b/drivers/gpu/drm/i915/intel_hdcp.c
>>index 98a9c81e2dc1..2db5da550a1c 100644
>>--- a/drivers/gpu/drm/i915/intel_hdcp.c
>>+++ b/drivers/gpu/drm/i915/intel_hdcp.c
>>@@ -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 */
>>--
>>2.9.3
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index 98a9c81e2dc1..2db5da550a1c 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -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 */