diff mbox series

[v3,2/2] USB: trancevibrator: simplify tv_probe

Message ID 20220812061805.88627-2-dzm91@hust.edu.cn
State New
Headers show
Series [v3,1/2] USB: trancevibrator: remove redundant space | expand

Commit Message

Dongliang Mu Aug. 12, 2022, 6:18 a.m. UTC
From: Dongliang Mu <mudongliangabcd@gmail.com>

The function tv_probe does not need to invoke kfree when the
allocation fails. So let's simplify the code of tv_probe.

Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
v2->v3: fix the truncated subject of PATCH 2/2.
v1->v2: no change

 drivers/usb/misc/trancevibrator.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Greg Kroah-Hartman Aug. 18, 2022, 3:06 p.m. UTC | #1
On Fri, Aug 12, 2022 at 02:18:02PM +0800, Dongliang Mu wrote:
> From: Dongliang Mu <mudongliangabcd@gmail.com>
> 
> The function tv_probe does not need to invoke kfree when the
> allocation fails. So let's simplify the code of tv_probe.
> 
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
> v2->v3: fix the truncated subject of PATCH 2/2.
> v1->v2: no change
> 
>  drivers/usb/misc/trancevibrator.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)

Note, I would recommend you work on basic "clean up" patches in the
drivers/staging/ directory so as to get experience on how to submit
patches properly before working in other parts of the kernel tree.  That
way subsystems that don't normally take "cleanup" patches don't get
bogged down in basic patch-process issues like this one did.

thanks,

greg k-h
Dongliang Mu Aug. 18, 2022, 3:15 p.m. UTC | #2
On Thu, Aug 18, 2022 at 11:06 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Aug 12, 2022 at 02:18:02PM +0800, Dongliang Mu wrote:
> > From: Dongliang Mu <mudongliangabcd@gmail.com>
> >
> > The function tv_probe does not need to invoke kfree when the
> > allocation fails. So let's simplify the code of tv_probe.
> >
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> > ---
> > v2->v3: fix the truncated subject of PATCH 2/2.
> > v1->v2: no change
> >
> >  drivers/usb/misc/trancevibrator.c | 11 ++---------
> >  1 file changed, 2 insertions(+), 9 deletions(-)
>
> Note, I would recommend you work on basic "clean up" patches in the
> drivers/staging/ directory so as to get experience on how to submit
> patches properly before working in other parts of the kernel tree.  That
> way subsystems that don't normally take "cleanup" patches don't get
> bogged down in basic patch-process issues like this one did.

I see. Thanks for your suggestion.

>
> thanks,
>
> greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 55cb63652eda..30d4d774d448 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -84,22 +84,15 @@  static int tv_probe(struct usb_interface *interface,
 {
 	struct usb_device *udev = interface_to_usbdev(interface);
 	struct trancevibrator *dev;
-	int retval;
 
 	dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL);
-	if (!dev) {
-		retval = -ENOMEM;
-		goto error;
-	}
+	if (!dev)
+		return -ENOMEM;
 
 	dev->udev = usb_get_dev(udev);
 	usb_set_intfdata(interface, dev);
 
 	return 0;
-
-error:
-	kfree(dev);
-	return retval;
 }
 
 static void tv_disconnect(struct usb_interface *interface)