All of lore.kernel.org
 help / color / mirror / Atom feed
* [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
@ 2019-05-10 10:11 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-05-10 10:11 UTC (permalink / raw)
  To: kbuild, Ramalingam C; +Cc: Daniel Vetter, intel-gfx, kbuild-all, dri-devel

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  

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-10 10:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-10 10:11 [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 Dan Carpenter

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.