Re: [PATCH 15/18] media: allegro: verify source and destination buffer in VCU response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v5.6-rc2 next-20200219]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Michael-Tretter/media-allegro-fixes-and-new-features/20200219-202330
base:   git://linuxtv.org/media_tree.git master
config: c6x-allyesconfig (attached as .config)
compiler: c6x-elf-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=c6x 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/staging/media/allegro-dvt/allegro-core.c: In function 'allegro_channel_finish_frame':
>> drivers/staging/media/allegro-dvt/allegro-core.c:1591:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     if ((u64)src_buf != msg->src_handle || (u64)dst_buf != msg->stream_id)
         ^
   drivers/staging/media/allegro-dvt/allegro-core.c:1591:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     if ((u64)src_buf != msg->src_handle || (u64)dst_buf != msg->stream_id)
                                            ^
   drivers/staging/media/allegro-dvt/allegro-core.c: In function 'allegro_device_run':
   drivers/staging/media/allegro-dvt/allegro-core.c:2964:71: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     allegro_mcu_send_put_stream_buffer(dev, channel, dst_addr, dst_size, (u64)dst_buf);
                                                                          ^
   drivers/staging/media/allegro-dvt/allegro-core.c:2971:61: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     allegro_mcu_send_encode_frame(dev, channel, src_y, src_uv, (u64)src_buf);
                                                                ^

vim +1591 drivers/staging/media/allegro-dvt/allegro-core.c

  1572	
  1573	static void allegro_channel_finish_frame(struct allegro_channel *channel,
  1574			struct mcu_msg_encode_frame_response *msg)
  1575	{
  1576		struct allegro_dev *dev = channel->dev;
  1577		struct vb2_v4l2_buffer *src_buf;
  1578		struct vb2_v4l2_buffer *dst_buf;
  1579		struct {
  1580			u32 offset;
  1581			u32 size;
  1582		} *partition;
  1583		enum vb2_buffer_state state = VB2_BUF_STATE_ERROR;
  1584		char *curr;
  1585		ssize_t len;
  1586		ssize_t free;
  1587	
  1588		src_buf = v4l2_m2m_src_buf_remove(channel->fh.m2m_ctx);
  1589		dst_buf = v4l2_m2m_dst_buf_remove(channel->fh.m2m_ctx);
  1590	
> 1591		if ((u64)src_buf != msg->src_handle || (u64)dst_buf != msg->stream_id)
  1592			v4l2_err(&dev->v4l2_dev,
  1593				 "channel %d: check failed\n",
  1594				 channel->mcu_channel_id);
  1595	
  1596		dst_buf->sequence = channel->csequence++;
  1597	
  1598		if (msg->error_code & AL_ERROR) {
  1599			v4l2_err(&dev->v4l2_dev,
  1600				 "channel %d: failed to encode frame: %s (%x)\n",
  1601				 channel->mcu_channel_id,
  1602				 allegro_err_to_string(msg->error_code),
  1603				 msg->error_code);
  1604			goto err;
  1605		}
  1606	
  1607		if (msg->partition_table_size != 1) {
  1608			v4l2_warn(&dev->v4l2_dev,
  1609				  "channel %d: only handling first partition table entry (%d entries)\n",
  1610				  channel->mcu_channel_id, msg->partition_table_size);
  1611		}
  1612	
  1613		if (msg->partition_table_offset +
  1614		    msg->partition_table_size * sizeof(*partition) >
  1615		    vb2_plane_size(&dst_buf->vb2_buf, 0)) {
  1616			v4l2_err(&dev->v4l2_dev,
  1617				 "channel %d: partition table outside of dst_buf\n",
  1618				 channel->mcu_channel_id);
  1619			goto err;
  1620		}
  1621	
  1622		partition =
  1623		    vb2_plane_vaddr(&dst_buf->vb2_buf, 0) + msg->partition_table_offset;
  1624		if (partition->offset + partition->size >
  1625		    vb2_plane_size(&dst_buf->vb2_buf, 0)) {
  1626			v4l2_err(&dev->v4l2_dev,
  1627				 "channel %d: encoded frame is outside of dst_buf (offset 0x%x, size 0x%x)\n",
  1628				 channel->mcu_channel_id, partition->offset,
  1629				 partition->size);
  1630			goto err;
  1631		}
  1632	
  1633		v4l2_dbg(2, debug, &dev->v4l2_dev,
  1634			 "channel %d: encoded frame of size %d is at offset 0x%x\n",
  1635			 channel->mcu_channel_id, partition->size, partition->offset);
  1636	
  1637		/*
  1638		 * The payload must include the data before the partition offset,
  1639		 * because we will put the sps and pps data there.
  1640		 */
  1641		vb2_set_plane_payload(&dst_buf->vb2_buf, 0,
  1642				      partition->offset + partition->size);
  1643	
  1644		curr = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
  1645		free = partition->offset;
  1646		if (msg->is_idr) {
  1647			len = allegro_h264_write_sps(channel, curr, free);
  1648			if (len < 0) {
  1649				v4l2_err(&dev->v4l2_dev,
  1650					 "not enough space for sequence parameter set: %zd left\n",
  1651					 free);
  1652				goto err;
  1653			}
  1654			curr += len;
  1655			free -= len;
  1656			v4l2_dbg(1, debug, &dev->v4l2_dev,
  1657				 "channel %d: wrote %zd byte SPS nal unit\n",
  1658				 channel->mcu_channel_id, len);
  1659		}
  1660	
  1661		if (msg->slice_type == AL_ENC_SLICE_TYPE_I) {
  1662			len = allegro_h264_write_pps(channel, curr, free);
  1663			if (len < 0) {
  1664				v4l2_err(&dev->v4l2_dev,
  1665					 "not enough space for picture parameter set: %zd left\n",
  1666					 free);
  1667				goto err;
  1668			}
  1669			curr += len;
  1670			free -= len;
  1671			v4l2_dbg(1, debug, &dev->v4l2_dev,
  1672				 "channel %d: wrote %zd byte PPS nal unit\n",
  1673				 channel->mcu_channel_id, len);
  1674		}
  1675	
  1676		if (msg->slice_type != AL_ENC_SLICE_TYPE_I && !msg->is_idr) {
  1677			dst_buf->vb2_buf.planes[0].data_offset = free;
  1678			free = 0;
  1679		} else {
  1680			len = nal_h264_write_filler(&dev->plat_dev->dev, curr, free);
  1681			if (len < 0) {
  1682				v4l2_err(&dev->v4l2_dev,
  1683						"failed to write %zd filler data\n", free);
  1684				goto err;
  1685			}
  1686			curr += len;
  1687			free -= len;
  1688			v4l2_dbg(2, debug, &dev->v4l2_dev,
  1689					"channel %d: wrote %zd bytes filler nal unit\n",
  1690					channel->mcu_channel_id, len);
  1691		}
  1692	
  1693		if (free != 0) {
  1694			v4l2_err(&dev->v4l2_dev,
  1695				 "non-VCL NAL units do not fill space until VCL NAL unit: %zd bytes left\n",
  1696				 free);
  1697			goto err;
  1698		}
  1699	
  1700		state = VB2_BUF_STATE_DONE;
  1701	
  1702		v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, false);
  1703		if (msg->is_idr)
  1704			dst_buf->flags |= V4L2_BUF_FLAG_KEYFRAME;
  1705		else
  1706			dst_buf->flags |= V4L2_BUF_FLAG_PFRAME;
  1707	
  1708		v4l2_dbg(1, debug, &dev->v4l2_dev,
  1709			 "channel %d: encoded frame #%03d (%s%s, QP %d, %d bytes)\n",
  1710			 channel->mcu_channel_id,
  1711			 dst_buf->sequence,
  1712			 msg->is_idr ? "IDR, " : "",
  1713			 msg->slice_type == AL_ENC_SLICE_TYPE_I ? "I slice" :
  1714			 msg->slice_type == AL_ENC_SLICE_TYPE_P ? "P slice" : "unknown",
  1715			 msg->qp, partition->size);
  1716	
  1717	err:
  1718		v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
  1719	
  1720		allegro_channel_buf_done(channel, dst_buf, state);
  1721	
  1722		v4l2_m2m_job_finish(dev->m2m_dev, channel->fh.m2m_ctx);
  1723	}
  1724	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux