linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: build warning after merge of the char-misc tree
@ 2017-12-12  3:39 Stephen Rothwell
  2017-12-12 10:40 ` [PATCH v2] misc: mic: Use memdup_user() as a cleanup Vasyl Gomonovych
  2017-12-12 11:49 ` linux-next: build warning after merge of the char-misc tree Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: Stephen Rothwell @ 2017-12-12  3:39 UTC (permalink / raw)
  To: Greg KH, Arnd Bergmann
  Cc: Linux-Next Mailing List, Linux Kernel Mailing List, Vasyl Gomonovych

Hi all,

After merging the char-misc tree, today's linux-next build
(x86_64_allmodconfig) produced this warning:

drivers/misc/mic/vop/vop_vringh.c: In function 'vop_ioctl':
drivers/misc/mic/vop/vop_vringh.c:1001:1: warning: label 'done' defined but not used [-Wunused-label]
 done:
 ^

Introduced by commit

  30b7a2c19e29 ("misc: mic: Use memdup_user() as a cleanup")

-- 
Cheers,
Stephen Rothwell

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] misc: mic: Use memdup_user() as a cleanup
  2017-12-12  3:39 linux-next: build warning after merge of the char-misc tree Stephen Rothwell
@ 2017-12-12 10:40 ` Vasyl Gomonovych
  2017-12-12 11:49   ` Greg KH
  2017-12-12 11:49 ` linux-next: build warning after merge of the char-misc tree Greg KH
  1 sibling, 1 reply; 6+ messages in thread
From: Vasyl Gomonovych @ 2017-12-12 10:40 UTC (permalink / raw)
  To: sfr, greg, arnd, sudeep.dutt, ashutosh.dixit, gomonovych, dan.carpenter
  Cc: linux-kernel, linux-next

Fix coccicheck warning which recommends to use memdup_user():

drivers/misc/mic/vop/vop_vringh.c:940:14-21: WARNING opportunity for memdup_user
drivers/misc/mic/vop/vop_vringh.c:998:8-15: WARNING opportunity for memdup_user

Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci

Changelog:
 - v1:
   - Replace kzalloc + copy_from_user on memdup_user
 - v2:
   - Clear forgotten done label
     After merging the char-misc tree, today's linux-next build
     (x86_64_allmodconfig) produced this warning:
     drivers/misc/mic/vop/vop_vringh.c: In function 'vop_ioctl':
     drivers/misc/mic/vop/vop_vringh.c:1001:1: warning: label 'done' defined but not used [-Wunused-label]

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
---
 drivers/misc/mic/vop/vop_vringh.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
index fed992e..27db64e 100644
--- a/drivers/misc/mic/vop/vop_vringh.c
+++ b/drivers/misc/mic/vop/vop_vringh.c
@@ -937,13 +937,10 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 		    dd.num_vq > MIC_MAX_VRINGS)
 			return -EINVAL;
 
-		dd_config = kzalloc(mic_desc_size(&dd), GFP_KERNEL);
-		if (!dd_config)
-			return -ENOMEM;
-		if (copy_from_user(dd_config, argp, mic_desc_size(&dd))) {
-			ret = -EFAULT;
-			goto free_ret;
-		}
+		dd_config = memdup_user(argp, mic_desc_size(&dd));
+		if (IS_ERR(dd_config))
+			return PTR_ERR(dd_config);
+
 		/* Ensure desc has not changed between the two reads */
 		if (memcmp(&dd, dd_config, sizeof(dd))) {
 			ret = -EINVAL;
@@ -995,17 +992,12 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 		ret = vop_vdev_inited(vdev);
 		if (ret)
 			goto __unlock_ret;
-		buf = kzalloc(vdev->dd->config_len, GFP_KERNEL);
-		if (!buf) {
-			ret = -ENOMEM;
+		buf = memdup_user(argp, vdev->dd->config_len);
+		if (IS_ERR(buf)) {
+			ret = PTR_ERR(buf);
 			goto __unlock_ret;
 		}
-		if (copy_from_user(buf, argp, vdev->dd->config_len)) {
-			ret = -EFAULT;
-			goto done;
-		}
 		ret = vop_virtio_config_change(vdev, buf);
-done:
 		kfree(buf);
 __unlock_ret:
 		mutex_unlock(&vdev->vdev_mutex);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] misc: mic: Use memdup_user() as a cleanup
  2017-12-12 10:40 ` [PATCH v2] misc: mic: Use memdup_user() as a cleanup Vasyl Gomonovych
@ 2017-12-12 11:49   ` Greg KH
  2017-12-12 13:22     ` Gomonovych, Vasyl
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2017-12-12 11:49 UTC (permalink / raw)
  To: Vasyl Gomonovych
  Cc: sfr, arnd, sudeep.dutt, ashutosh.dixit, dan.carpenter,
	linux-kernel, linux-next

On Tue, Dec 12, 2017 at 11:40:58AM +0100, Vasyl Gomonovych wrote:
> Fix coccicheck warning which recommends to use memdup_user():
> 
> drivers/misc/mic/vop/vop_vringh.c:940:14-21: WARNING opportunity for memdup_user
> drivers/misc/mic/vop/vop_vringh.c:998:8-15: WARNING opportunity for memdup_user
> 
> Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci
> 
> Changelog:
>  - v1:
>    - Replace kzalloc + copy_from_user on memdup_user
>  - v2:
>    - Clear forgotten done label
>      After merging the char-misc tree, today's linux-next build
>      (x86_64_allmodconfig) produced this warning:
>      drivers/misc/mic/vop/vop_vringh.c: In function 'vop_ioctl':
>      drivers/misc/mic/vop/vop_vringh.c:1001:1: warning: label 'done' defined but not used [-Wunused-label]

Will not work as I already have taken v1.

Also, put the changelog below the --- line please.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: linux-next: build warning after merge of the char-misc tree
  2017-12-12  3:39 linux-next: build warning after merge of the char-misc tree Stephen Rothwell
  2017-12-12 10:40 ` [PATCH v2] misc: mic: Use memdup_user() as a cleanup Vasyl Gomonovych
@ 2017-12-12 11:49 ` Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Greg KH @ 2017-12-12 11:49 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Arnd Bergmann, Linux-Next Mailing List,
	Linux Kernel Mailing List, Vasyl Gomonovych

On Tue, Dec 12, 2017 at 02:39:10PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the char-misc tree, today's linux-next build
> (x86_64_allmodconfig) produced this warning:
> 
> drivers/misc/mic/vop/vop_vringh.c: In function 'vop_ioctl':
> drivers/misc/mic/vop/vop_vringh.c:1001:1: warning: label 'done' defined but not used [-Wunused-label]
>  done:
>  ^
> 
> Introduced by commit
> 
>   30b7a2c19e29 ("misc: mic: Use memdup_user() as a cleanup")

Thanks, Colin sent a patch for this, will queue it up later today.

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] misc: mic: Use memdup_user() as a cleanup
  2017-12-12 11:49   ` Greg KH
@ 2017-12-12 13:22     ` Gomonovych, Vasyl
  2017-12-13  9:30       ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Gomonovych, Vasyl @ 2017-12-12 13:22 UTC (permalink / raw)
  To: Greg KH
  Cc: Stephen Rothwell, Arnd Bergmann, sudeep.dutt, ashutosh.dixit,
	dan.carpenter, linux-kernel, linux-next

Hi,
Thanks.
Should I prepare fix patch only for missed label?

Regards Vasyl.

On Tue, Dec 12, 2017 at 12:49 PM, Greg KH <greg@kroah.com> wrote:
> On Tue, Dec 12, 2017 at 11:40:58AM +0100, Vasyl Gomonovych wrote:
>> Fix coccicheck warning which recommends to use memdup_user():
>>
>> drivers/misc/mic/vop/vop_vringh.c:940:14-21: WARNING opportunity for memdup_user
>> drivers/misc/mic/vop/vop_vringh.c:998:8-15: WARNING opportunity for memdup_user
>>
>> Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci
>>
>> Changelog:
>>  - v1:
>>    - Replace kzalloc + copy_from_user on memdup_user
>>  - v2:
>>    - Clear forgotten done label
>>      After merging the char-misc tree, today's linux-next build
>>      (x86_64_allmodconfig) produced this warning:
>>      drivers/misc/mic/vop/vop_vringh.c: In function 'vop_ioctl':
>>      drivers/misc/mic/vop/vop_vringh.c:1001:1: warning: label 'done' defined but not used [-Wunused-label]
>
> Will not work as I already have taken v1.
>
> Also, put the changelog below the --- line please.
>
> thanks,
>
> greg k-h



-- 
Доброї вам пори дня.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] misc: mic: Use memdup_user() as a cleanup
  2017-12-12 13:22     ` Gomonovych, Vasyl
@ 2017-12-13  9:30       ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2017-12-13  9:30 UTC (permalink / raw)
  To: Gomonovych, Vasyl
  Cc: Stephen Rothwell, Arnd Bergmann, sudeep.dutt, ashutosh.dixit,
	dan.carpenter, linux-kernel, linux-next

On Tue, Dec 12, 2017 at 02:22:41PM +0100, Gomonovych, Vasyl wrote:
> Hi,
> Thanks.
> Should I prepare fix patch only for missed label?

I have no context here at all, sorry...

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-13  9:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12  3:39 linux-next: build warning after merge of the char-misc tree Stephen Rothwell
2017-12-12 10:40 ` [PATCH v2] misc: mic: Use memdup_user() as a cleanup Vasyl Gomonovych
2017-12-12 11:49   ` Greg KH
2017-12-12 13:22     ` Gomonovych, Vasyl
2017-12-13  9:30       ` Greg KH
2017-12-12 11:49 ` linux-next: build warning after merge of the char-misc tree Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).