[staging:staging-next 50/93] drivers/staging/wfx/debug.c:112 wfx_send_hif_msg_read() warn: maybe return -EFAULT instead of the bytes remaining?

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next
head:   e772cd8c9c9cd3d08715800aabaf50b771b395d9
commit: 4f8b7fabb15df3658564a98971fc67029be1815d [50/93] staging: wfx: allow to send commands to chip

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

smatch warnings:
drivers/staging/wfx/debug.c:112 wfx_send_hif_msg_read() warn: maybe return -EFAULT instead of the bytes remaining?

# https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=4f8b7fabb15df3658564a98971fc67029be1815d
git remote add staging https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
git remote update staging
git checkout 4f8b7fabb15df3658564a98971fc67029be1815d
vim +112 drivers/staging/wfx/debug.c

4f8b7fabb15df3 Jérôme Pouiller 2019-09-19   95  static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19   96  				     size_t count, loff_t *ppos)
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19   97  {
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19   98  	struct dbgfs_hif_msg *context = file->private_data;
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19   99  	int ret;
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  100  
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  101  	if (count > sizeof(context->reply))
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  102  		return -EINVAL;
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  103  	ret = wait_for_completion_interruptible(&context->complete);
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  104  	if (ret)
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  105  		return ret;
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  106  	if (context->ret < 0)
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  107  		return context->ret;
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  108  	// Be carefull, write() is waiting for a full message while read()
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  109  	// only return a payload
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  110  	ret = copy_to_user(user_buf, context->reply, count);
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  111  	if (ret)
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19 @112  		return ret;

Yeah.  It should be:

	if (copy_to_user(user_buf, context->reply, count))
		return -EFAULT;

4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  113  
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  114  	return count;
4f8b7fabb15df3 Jérôme Pouiller 2019-09-19  115  }

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux