DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [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?
@ 2019-10-08  4:35 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-10-08  4:35 UTC (permalink / raw)
  To: kbuild, Jérôme Pouiller; +Cc: devel, Greg Kroah-Hartman, kbuild-all

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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

only message in thread, back to index

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

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org driverdev-devel@archiver.kernel.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox