All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@01.org, Ramalingam C <ramalingam.c@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org, kbuild-all@01.org,
	dri-devel@lists.freedesktop.org
Subject: [drm-intel:drm-intel-next-queued 4/6] drivers/gpu/drm/drm_hdcp.c:190 drm_hdcp_parse_hdcp2_srm() warn: mask and shift to zero
Date: Fri, 10 May 2019 13:11:42 +0300	[thread overview]
Message-ID: <20190510101141.GC16030@kadam> (raw)

tree:   git://anongit.freedesktop.org/drm-intel drm-intel-next-queued
head:   c16fd9be70faf3c49a61700efd16018dd910e390
commit: 6498bf5800a302ef69e7f4914e727893f278bb2f [4/6] drm: revocation check at drm subsystem

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/drm_hdcp.c:190 drm_hdcp_parse_hdcp2_srm() warn: mask and shift to zero

git remote add drm-intel git://anongit.freedesktop.org/drm-intel
git remote update drm-intel
git checkout 6498bf5800a302ef69e7f4914e727893f278bb2f
vim +190 drivers/gpu/drm/drm_hdcp.c

6498bf58 Ramalingam C 2019-05-07  151  static int drm_hdcp_parse_hdcp2_srm(const u8 *buf, size_t count)
6498bf58 Ramalingam C 2019-05-07  152  {
6498bf58 Ramalingam C 2019-05-07  153  	struct hdcp_srm_header *header;
6498bf58 Ramalingam C 2019-05-07  154  	u32 vrl_length, ksv_count, ksv_sz;
6498bf58 Ramalingam C 2019-05-07  155  
6498bf58 Ramalingam C 2019-05-07  156  	if (count < (sizeof(struct hdcp_srm_header) +
6498bf58 Ramalingam C 2019-05-07  157  	    DRM_HDCP_2_VRL_LENGTH_SIZE + DRM_HDCP_2_DCP_SIG_SIZE)) {
6498bf58 Ramalingam C 2019-05-07  158  		DRM_ERROR("Invalid blob length\n");
6498bf58 Ramalingam C 2019-05-07  159  		return -EINVAL;
6498bf58 Ramalingam C 2019-05-07  160  	}
6498bf58 Ramalingam C 2019-05-07  161  
6498bf58 Ramalingam C 2019-05-07  162  	header = (struct hdcp_srm_header *)buf;
6498bf58 Ramalingam C 2019-05-07  163  	DRM_DEBUG("SRM ID: 0x%x, SRM Ver: 0x%x, SRM Gen No: 0x%x\n",
6498bf58 Ramalingam C 2019-05-07  164  		  header->srm_id & DRM_HDCP_SRM_ID_MASK,
6498bf58 Ramalingam C 2019-05-07  165  		  be16_to_cpu(header->srm_version), header->srm_gen_no);
6498bf58 Ramalingam C 2019-05-07  166  
6498bf58 Ramalingam C 2019-05-07  167  	if (header->reserved)
6498bf58 Ramalingam C 2019-05-07  168  		return -EINVAL;
6498bf58 Ramalingam C 2019-05-07  169  
6498bf58 Ramalingam C 2019-05-07  170  	buf = buf + sizeof(*header);
6498bf58 Ramalingam C 2019-05-07  171  	vrl_length = get_vrl_length(buf);
6498bf58 Ramalingam C 2019-05-07  172  
6498bf58 Ramalingam C 2019-05-07  173  	if (count < (sizeof(struct hdcp_srm_header) + vrl_length) ||
6498bf58 Ramalingam C 2019-05-07  174  	    vrl_length < (DRM_HDCP_2_VRL_LENGTH_SIZE +
6498bf58 Ramalingam C 2019-05-07  175  	    DRM_HDCP_2_DCP_SIG_SIZE)) {
6498bf58 Ramalingam C 2019-05-07  176  		DRM_ERROR("Invalid blob length or vrl length\n");
6498bf58 Ramalingam C 2019-05-07  177  		return -EINVAL;
6498bf58 Ramalingam C 2019-05-07  178  	}
6498bf58 Ramalingam C 2019-05-07  179  
6498bf58 Ramalingam C 2019-05-07  180  	/* Length of the all vrls combined */
6498bf58 Ramalingam C 2019-05-07  181  	vrl_length -= (DRM_HDCP_2_VRL_LENGTH_SIZE +
6498bf58 Ramalingam C 2019-05-07  182  		       DRM_HDCP_2_DCP_SIG_SIZE);
6498bf58 Ramalingam C 2019-05-07  183  
6498bf58 Ramalingam C 2019-05-07  184  	if (!vrl_length) {
6498bf58 Ramalingam C 2019-05-07  185  		DRM_ERROR("No vrl found\n");
6498bf58 Ramalingam C 2019-05-07  186  		return -EINVAL;
6498bf58 Ramalingam C 2019-05-07  187  	}
6498bf58 Ramalingam C 2019-05-07  188  
6498bf58 Ramalingam C 2019-05-07  189  	buf += DRM_HDCP_2_VRL_LENGTH_SIZE;
6498bf58 Ramalingam C 2019-05-07 @190  	ksv_count = (*buf << 2) | DRM_HDCP_2_KSV_COUNT_2_LSBITS(*(buf + 1));

#define DRM_HDCP_2_KSV_COUNT_2_LSBITS(byte)     (((byte) & 0xC) >> 6)

0xC >> 6 is always zero.

6498bf58 Ramalingam C 2019-05-07  191  	if (!ksv_count) {
6498bf58 Ramalingam C 2019-05-07  192  		DRM_DEBUG("Revoked KSV count is 0\n");
6498bf58 Ramalingam C 2019-05-07  193  		return count;
6498bf58 Ramalingam C 2019-05-07  194  	}
6498bf58 Ramalingam C 2019-05-07  195  

                 reply	other threads:[~2019-05-10 10:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190510101141.GC16030@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kbuild-all@01.org \
    --cc=kbuild@01.org \
    --cc=ramalingam.c@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.