Merge tag 'media/v6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media fix from Mauro Carvalho Chehab:
"A revert for a regression in the uvcvideo driver"

* tag 'media/v6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
Revert "media: uvcvideo: Require entities to have a non-zero unique ID"

+27 -43
+27 -43
drivers/media/usb/uvc/uvc_driver.c
··· 790 UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; 791 static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; 792 793 - static struct uvc_entity *uvc_alloc_new_entity(struct uvc_device *dev, u16 type, 794 - u16 id, unsigned int num_pads, 795 - unsigned int extra_size) 796 { 797 struct uvc_entity *entity; 798 unsigned int num_inputs; 799 unsigned int size; 800 unsigned int i; 801 - 802 - /* Per UVC 1.1+ spec 3.7.2, the ID should be non-zero. */ 803 - if (id == 0) { 804 - dev_err(&dev->udev->dev, "Found Unit with invalid ID 0.\n"); 805 - return ERR_PTR(-EINVAL); 806 - } 807 - 808 - /* Per UVC 1.1+ spec 3.7.2, the ID is unique. */ 809 - if (uvc_entity_by_id(dev, id)) { 810 - dev_err(&dev->udev->dev, "Found multiple Units with ID %u\n", id); 811 - return ERR_PTR(-EINVAL); 812 - } 813 814 extra_size = roundup(extra_size, sizeof(*entity->pads)); 815 if (num_pads) ··· 807 + num_inputs; 808 entity = kzalloc(size, GFP_KERNEL); 809 if (entity == NULL) 810 - return ERR_PTR(-ENOMEM); 811 812 entity->id = id; 813 entity->type = type; ··· 919 break; 920 } 921 922 - unit = uvc_alloc_new_entity(dev, UVC_VC_EXTENSION_UNIT, 923 - buffer[3], p + 1, 2 * n); 924 - if (IS_ERR(unit)) 925 - return PTR_ERR(unit); 926 927 memcpy(unit->guid, &buffer[4], 16); 928 unit->extension.bNumControls = buffer[20]; ··· 1031 return -EINVAL; 1032 } 1033 1034 - term = uvc_alloc_new_entity(dev, type | UVC_TERM_INPUT, 1035 - buffer[3], 1, n + p); 1036 - if (IS_ERR(term)) 1037 - return PTR_ERR(term); 1038 1039 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) { 1040 term->camera.bControlSize = n; ··· 1090 return 0; 1091 } 1092 1093 - term = uvc_alloc_new_entity(dev, type | UVC_TERM_OUTPUT, 1094 - buffer[3], 1, 0); 1095 - if (IS_ERR(term)) 1096 - return PTR_ERR(term); 1097 1098 memcpy(term->baSourceID, &buffer[7], 1); 1099 ··· 1112 return -EINVAL; 1113 } 1114 1115 - unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 1116 - p + 1, 0); 1117 - if (IS_ERR(unit)) 1118 - return PTR_ERR(unit); 1119 1120 memcpy(unit->baSourceID, &buffer[5], p); 1121 ··· 1134 return -EINVAL; 1135 } 1136 1137 - unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 2, n); 1138 - if (IS_ERR(unit)) 1139 - return PTR_ERR(unit); 1140 1141 memcpy(unit->baSourceID, &buffer[4], 1); 1142 unit->processing.wMaxMultiplier = ··· 1163 return -EINVAL; 1164 } 1165 1166 - unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 1167 - p + 1, n); 1168 - if (IS_ERR(unit)) 1169 - return PTR_ERR(unit); 1170 1171 memcpy(unit->guid, &buffer[4], 16); 1172 unit->extension.bNumControls = buffer[20]; ··· 1305 return dev_err_probe(&dev->intf->dev, irq, 1306 "No IRQ for privacy GPIO\n"); 1307 1308 - unit = uvc_alloc_new_entity(dev, UVC_EXT_GPIO_UNIT, 1309 - UVC_EXT_GPIO_UNIT_ID, 0, 1); 1310 - if (IS_ERR(unit)) 1311 - return PTR_ERR(unit); 1312 1313 unit->gpio.gpio_privacy = gpio_privacy; 1314 unit->gpio.irq = irq;
··· 790 UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; 791 static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; 792 793 + static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, 794 + unsigned int num_pads, unsigned int extra_size) 795 { 796 struct uvc_entity *entity; 797 unsigned int num_inputs; 798 unsigned int size; 799 unsigned int i; 800 801 extra_size = roundup(extra_size, sizeof(*entity->pads)); 802 if (num_pads) ··· 820 + num_inputs; 821 entity = kzalloc(size, GFP_KERNEL); 822 if (entity == NULL) 823 + return NULL; 824 825 entity->id = id; 826 entity->type = type; ··· 932 break; 933 } 934 935 + unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3], 936 + p + 1, 2*n); 937 + if (unit == NULL) 938 + return -ENOMEM; 939 940 memcpy(unit->guid, &buffer[4], 16); 941 unit->extension.bNumControls = buffer[20]; ··· 1044 return -EINVAL; 1045 } 1046 1047 + term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3], 1048 + 1, n + p); 1049 + if (term == NULL) 1050 + return -ENOMEM; 1051 1052 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) { 1053 term->camera.bControlSize = n; ··· 1103 return 0; 1104 } 1105 1106 + term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3], 1107 + 1, 0); 1108 + if (term == NULL) 1109 + return -ENOMEM; 1110 1111 memcpy(term->baSourceID, &buffer[7], 1); 1112 ··· 1125 return -EINVAL; 1126 } 1127 1128 + unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0); 1129 + if (unit == NULL) 1130 + return -ENOMEM; 1131 1132 memcpy(unit->baSourceID, &buffer[5], p); 1133 ··· 1148 return -EINVAL; 1149 } 1150 1151 + unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n); 1152 + if (unit == NULL) 1153 + return -ENOMEM; 1154 1155 memcpy(unit->baSourceID, &buffer[4], 1); 1156 unit->processing.wMaxMultiplier = ··· 1177 return -EINVAL; 1178 } 1179 1180 + unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n); 1181 + if (unit == NULL) 1182 + return -ENOMEM; 1183 1184 memcpy(unit->guid, &buffer[4], 16); 1185 unit->extension.bNumControls = buffer[20]; ··· 1320 return dev_err_probe(&dev->intf->dev, irq, 1321 "No IRQ for privacy GPIO\n"); 1322 1323 + unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); 1324 + if (!unit) 1325 + return -ENOMEM; 1326 1327 unit->gpio.gpio_privacy = gpio_privacy; 1328 unit->gpio.irq = irq;