hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/usb/siano/smsusb.c
....@@ -1,21 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /****************************************************************
23
34 Siano Mobile Silicon, Inc.
45 MDTV receiver kernel modules.
56 Copyright (C) 2005-2009, Uri Shkolnik, Anatoly Greenblat
67
7
-This program is free software: you can redistribute it and/or modify
8
-it under the terms of the GNU General Public License as published by
9
-the Free Software Foundation, either version 2 of the License, or
10
-(at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
-but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
-GNU General Public License for more details.
16
-
17
-You should have received a copy of the GNU General Public License
18
-along with this program. If not, see <http://www.gnu.org/licenses/>.
198
209 ****************************************************************/
2110
....@@ -75,7 +64,7 @@
7564 struct smsusb_urb_t *surb);
7665
7766 /*
78
- * Completing URB's callback handler - bottom half (proccess context)
67
+ * Completing URB's callback handler - bottom half (process context)
7968 * submits the URB prepared on smsusb_onresponse()
8069 */
8170 static void do_submit_urb(struct work_struct *work)
....@@ -190,6 +179,8 @@
190179
191180 for (i = 0; i < MAX_URBS; i++) {
192181 usb_kill_urb(&dev->surbs[i].urb);
182
+ if (dev->surbs[i].wq.func)
183
+ cancel_work_sync(&dev->surbs[i].wq);
193184
194185 if (dev->surbs[i].cb) {
195186 smscore_putbuffer(dev->coredev, dev->surbs[i].cb);
....@@ -225,10 +216,9 @@
225216 return -ENOENT;
226217 }
227218
228
- phdr = kmalloc(size, GFP_KERNEL);
219
+ phdr = kmemdup(buffer, size, GFP_KERNEL);
229220 if (!phdr)
230221 return -ENOMEM;
231
- memcpy(phdr, buffer, size);
232222
233223 pr_debug("sending %s(%d) size: %d\n",
234224 smscore_translate_msg(phdr->msg_type), phdr->msg_type,
....@@ -442,7 +432,7 @@
442432 break;
443433 case SMS_UNKNOWN_TYPE:
444434 pr_err("Unspecified sms device type!\n");
445
- /* fall-thru */
435
+ fallthrough;
446436 default:
447437 dev->buffer_size = USB2_BUFFER_SIZE;
448438 dev->response_alignment = align;
....@@ -465,12 +455,7 @@
465455 rc = smscore_register_device(&params, &dev->coredev, 0, mdev);
466456 if (rc < 0) {
467457 pr_err("smscore_register_device(...) failed, rc %d\n", rc);
468
- smsusb_term_device(intf);
469
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
470
- media_device_unregister(mdev);
471
-#endif
472
- kfree(mdev);
473
- return rc;
458
+ goto err_unregister_device;
474459 }
475460
476461 smscore_set_board_id(dev->coredev, board_id);
....@@ -487,8 +472,7 @@
487472 rc = smsusb_start_streaming(dev);
488473 if (rc < 0) {
489474 pr_err("smsusb_start_streaming(...) failed\n");
490
- smsusb_term_device(intf);
491
- return rc;
475
+ goto err_unregister_device;
492476 }
493477
494478 dev->state = SMSUSB_ACTIVE;
....@@ -496,13 +480,20 @@
496480 rc = smscore_start_device(dev->coredev);
497481 if (rc < 0) {
498482 pr_err("smscore_start_device(...) failed\n");
499
- smsusb_term_device(intf);
500
- return rc;
483
+ goto err_unregister_device;
501484 }
502485
503486 pr_debug("device 0x%p created\n", dev);
504487
505488 return rc;
489
+
490
+err_unregister_device:
491
+ smsusb_term_device(intf);
492
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
493
+ media_device_unregister(mdev);
494
+#endif
495
+ kfree(mdev);
496
+ return rc;
506497 }
507498
508499 static int smsusb_probe(struct usb_interface *intf,