From: Jani Nikula <jani.nikula@linux.intel.com>
To: Radhakrishna Sripada <radhakrishna.sripada@intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/i915: Fix memory leak in intel_hdcp auth
Date: Wed, 04 Apr 2018 15:04:07 +0300 [thread overview]
Message-ID: <87sh8bfaa0.fsf@intel.com> (raw)
In-Reply-To: <20180404000456.1407-1-radhakrishna.sripada@intel.com>
On Tue, 03 Apr 2018, Radhakrishna Sripada <radhakrishna.sripada@intel.com> wrote:
> Static code analysis tool reported memory leak in
> intel_hdcp_auth_downstream. Fixing the memory leak.
>
> Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-04-04 12:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-04 0:04 [PATCH 1/2] drm/i915: Fix memory leak in intel_hdcp auth Radhakrishna Sripada
2018-04-04 0:04 ` [PATCH 2/2] drm/i915: Use int instead of u32 to cache GuC logging level Radhakrishna Sripada
2018-04-04 0:36 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Fix memory leak in intel_hdcp auth Patchwork
2018-04-04 1:20 ` ✓ Fi.CI.IGT: " Patchwork
2018-04-04 12:04 ` Jani Nikula [this message]
2018-04-04 23:05 ` [PATCH 1/2] " Srivatsa, Anusha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sh8bfaa0.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=radhakrishna.sripada@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox