[Intel-gfx] [PATCH 1/2] drm/i915: Fix memory leak in intel_hdcp auth
Jani Nikula
jani.nikula at linux.intel.com
Wed Apr 4 12:04:07 UTC 2018
On Tue, 03 Apr 2018, Radhakrishna Sripada <radhakrishna.sripada at intel.com> wrote:
> Static code analysis tool reported memory leak in
> intel_hdcp_auth_downstream. Fixing the memory leak.
>
> Cc: Anusha Srivatsa <anusha.srivatsa at intel.com>
> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada at intel.com>
> ---
> drivers/gpu/drm/i915/intel_hdcp.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
> index 14ca5d3057a7..ce771f6c1a5a 100644
> --- a/drivers/gpu/drm/i915/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/intel_hdcp.c
> @@ -186,14 +186,18 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
> return -ENOMEM;
>
> ret = shim->read_ksv_fifo(intel_dig_port, num_downstream, ksv_fifo);
> - if (ret)
> + if (ret) {
> + kfree(ksv_fifo);
Please add an single cleanup label and goto it from all error paths.
BR,
Jani.
> return ret;
> + }
>
> /* Process V' values from the receiver */
> for (i = 0; i < DRM_HDCP_V_PRIME_NUM_PARTS; i++) {
> ret = shim->read_v_prime_part(intel_dig_port, i, &vprime);
> - if (ret)
> + if (ret) {
> + kfree(ksv_fifo);
> return ret;
> + }
> I915_WRITE(HDCP_SHA_V_PRIME(i), vprime);
> }
>
> @@ -222,8 +226,10 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
> sha_text |= ksv[j] << ((sizeof(sha_text) - j - 1) * 8);
>
> ret = intel_write_sha_text(dev_priv, sha_text);
> - if (ret < 0)
> + if (ret < 0) {
> + kfree(ksv_fifo);
> return ret;
> + }
>
> /* Programming guide writes this every 64 bytes */
> sha_idx += sizeof(sha_text);
> @@ -245,13 +251,18 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
> continue;
>
> ret = intel_write_sha_text(dev_priv, sha_text);
> - if (ret < 0)
> + if (ret < 0) {
> + kfree(ksv_fifo);
> return ret;
> + }
> +
> sha_leftovers = 0;
> sha_text = 0;
> sha_idx += sizeof(sha_text);
> }
>
> + kfree(ksv_fifo);
> +
> /*
> * We need to write BINFO/BSTATUS, and M0 now. Depending on how many
> * bytes are leftover from the last ksv, we might be able to fit them
--
Jani Nikula, Intel Open Source Technology Center
More information about the Intel-gfx
mailing list