From patchwork Wed Apr 4 00:04:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 10321865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F47460541 for ; Wed, 4 Apr 2018 00:03:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92A2C28D2E for ; Wed, 4 Apr 2018 00:03:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8704C28D33; Wed, 4 Apr 2018 00:03:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D02E28D2E for ; Wed, 4 Apr 2018 00:03:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C5EA6E5EC; Wed, 4 Apr 2018 00:03:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 606886E5EC for ; Wed, 4 Apr 2018 00:03:03 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 17:03:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,403,1517904000"; d="scan'208";a="43178827" Received: from invictus.jf.intel.com ([10.54.75.152]) by fmsmga004.fm.intel.com with ESMTP; 03 Apr 2018 17:03:02 -0700 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Date: Tue, 3 Apr 2018 17:04:55 -0700 Message-Id: <20180404000456.1407-1-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.9.3 Subject: [Intel-gfx] [PATCH 1/2] drm/i915: Fix memory leak in intel_hdcp auth X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Static code analysis tool reported memory leak in intel_hdcp_auth_downstream. Fixing the memory leak. Cc: Anusha Srivatsa Signed-off-by: Radhakrishna Sripada Reviewed-by: Anusha Srivatsa --- 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); 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