forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/go7007/go7007-usb.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2005-2006 Micronas USA Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License (Version 2) as
6
- * published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -1133,12 +1125,16 @@
11331125 usb->usbdev = usbdev;
11341126 usb_make_path(usbdev, go->bus_info, sizeof(go->bus_info));
11351127 go->board_id = id->driver_info;
1136
- strncpy(go->name, name, sizeof(go->name));
1128
+ strscpy(go->name, name, sizeof(go->name));
11371129 if (board->flags & GO7007_USB_EZUSB)
11381130 go->hpi_ops = &go7007_usb_ezusb_hpi_ops;
11391131 else
11401132 go->hpi_ops = &go7007_usb_onboard_hpi_ops;
11411133 go->hpi_context = usb;
1134
+
1135
+ ep = usb->usbdev->ep_in[4];
1136
+ if (!ep)
1137
+ goto allocfail;
11421138
11431139 /* Allocate the URB and buffer for receiving incoming interrupts */
11441140 usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
....@@ -1149,7 +1145,6 @@
11491145 if (usb->intr_urb->transfer_buffer == NULL)
11501146 goto allocfail;
11511147
1152
- ep = usb->usbdev->ep_in[4];
11531148 if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
11541149 usb_fill_bulk_urb(usb->intr_urb, usb->usbdev,
11551150 usb_rcvbulkpipe(usb->usbdev, 4),
....@@ -1200,7 +1195,7 @@
12001195 go->board_id = GO7007_BOARDID_ENDURA;
12011196 usb->board = board = &board_endura;
12021197 go->board_info = &board->main_info;
1203
- strncpy(go->name, "Pelco Endura",
1198
+ strscpy(go->name, "Pelco Endura",
12041199 sizeof(go->name));
12051200 } else {
12061201 u16 channel;
....@@ -1234,21 +1229,21 @@
12341229 case 1:
12351230 go->tuner_type = TUNER_SONY_BTF_PG472Z;
12361231 go->std = V4L2_STD_PAL;
1237
- strncpy(go->name, "Plextor PX-TV402U-EU",
1238
- sizeof(go->name));
1232
+ strscpy(go->name, "Plextor PX-TV402U-EU",
1233
+ sizeof(go->name));
12391234 break;
12401235 case 2:
12411236 go->tuner_type = TUNER_SONY_BTF_PK467Z;
12421237 go->std = V4L2_STD_NTSC_M_JP;
12431238 num_i2c_devs -= 2;
1244
- strncpy(go->name, "Plextor PX-TV402U-JP",
1245
- sizeof(go->name));
1239
+ strscpy(go->name, "Plextor PX-TV402U-JP",
1240
+ sizeof(go->name));
12461241 break;
12471242 case 3:
12481243 go->tuner_type = TUNER_SONY_BTF_PB463Z;
12491244 num_i2c_devs -= 2;
1250
- strncpy(go->name, "Plextor PX-TV402U-NA",
1251
- sizeof(go->name));
1245
+ strscpy(go->name, "Plextor PX-TV402U-NA",
1246
+ sizeof(go->name));
12521247 break;
12531248 default:
12541249 pr_debug("unable to detect tuner type!\n");
....@@ -1271,9 +1266,13 @@
12711266
12721267 /* Allocate the URBs and buffers for receiving the video stream */
12731268 if (board->flags & GO7007_USB_EZUSB) {
1269
+ if (!usb->usbdev->ep_in[6])
1270
+ goto allocfail;
12741271 v_urb_len = 1024;
12751272 video_pipe = usb_rcvbulkpipe(usb->usbdev, 6);
12761273 } else {
1274
+ if (!usb->usbdev->ep_in[1])
1275
+ goto allocfail;
12771276 v_urb_len = 512;
12781277 video_pipe = usb_rcvbulkpipe(usb->usbdev, 1);
12791278 }
....@@ -1293,6 +1292,8 @@
12931292 /* Allocate the URBs and buffers for receiving the audio stream */
12941293 if ((board->flags & GO7007_USB_EZUSB) &&
12951294 (board->main_info.flags & GO7007_BOARD_HAS_AUDIO)) {
1295
+ if (!usb->usbdev->ep_in[8])
1296
+ goto allocfail;
12961297 for (i = 0; i < 8; ++i) {
12971298 usb->audio_urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
12981299 if (usb->audio_urbs[i] == NULL)