History

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"

Linus Torvalds committed 1 year ago

Commit c6fe03a2 parents 60c828c 8004d631 file · +27 −43Browse files

Unified · Split

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