diff mbox series

[2/2] USB: ncevibrator: simplify tv_probe

Message ID 20220811025346.113199-2-dzm91@hust.edu.cn (mailing list archive)
State Superseded
Headers show
Series [1/2] USB: trancevibrator: remove redundant space | expand

Commit Message

Dongliang Mu Aug. 11, 2022, 2:53 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>
---
 drivers/usb/misc/trancevibrator.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Sergey Shtylyov Aug. 11, 2022, 8:34 a.m. UTC | #1
Hello!

   Your subject is broken now. :-)

MBR, Sergey
Dongliang Mu Aug. 11, 2022, 8:57 a.m. UTC | #2
On Thu, Aug 11, 2022 at 4:34 PM Sergey Shtylyov <s.shtylyov@omp.ru> wrote:
>
> Hello!
>
>    Your subject is broken now. :-)

Yes, thanks for your reminder. Will send a v2 patch.

>
> MBR, Sergey
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)