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
790790 UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT;
791791 static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING;
792792
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)
793+static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,
794+ unsigned int num_pads, unsigned int extra_size)
796795 {
797796 struct uvc_entity *entity;
798797 unsigned int num_inputs;
799798 unsigned int size;
800799 unsigned int i;
801800
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−
814801 extra_size = roundup(extra_size, sizeof(*entity->pads));
815802 if (num_pads)
816803 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
820807 + num_inputs;
821808 entity = kzalloc(size, GFP_KERNEL);
822809 if (entity == NULL)
823− return ERR_PTR(-ENOMEM);
810+ return NULL;
824811
825812 entity->id = id;
826813 entity->type = type;
@@ -932,10 +919,10 @@ static int uvc_parse_vendor_control(struct uvc_device *dev, · 105 unmodified lines
932919 break;
933920 }
934921
935− unit = uvc_alloc_new_entity(dev, UVC_VC_EXTENSION_UNIT,
936− buffer[3], p + 1, 2 * n);
937− if (IS_ERR(unit))
938− return PTR_ERR(unit);
922+ unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3],
923+ p + 1, 2*n);
924+ if (unit == NULL)
925+ return -ENOMEM;
939926
940927 memcpy(unit->guid, &buffer[4], 16);
941928 unit->extension.bNumControls = buffer[20];
@@ -1044,10 +1031,10 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 102 unmodified lines
10441031 return -EINVAL;
10451032 }
10461033
1047− term = uvc_alloc_new_entity(dev, type | UVC_TERM_INPUT,
1048− buffer[3], 1, n + p);
1049− if (IS_ERR(term))
1050− return PTR_ERR(term);
1034+ term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3],
1035+ 1, n + p);
1036+ if (term == NULL)
1037+ return -ENOMEM;
10511038
10521039 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) {
10531040 term->camera.bControlSize = n;
@@ -1103,10 +1090,10 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 49 unmodified lines
11031090 return 0;
11041091 }
11051092
1106− term = uvc_alloc_new_entity(dev, type | UVC_TERM_OUTPUT,
1107− buffer[3], 1, 0);
1108− if (IS_ERR(term))
1109− return PTR_ERR(term);
1093+ term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3],
1094+ 1, 0);
1095+ if (term == NULL)
1096+ return -ENOMEM;
11101097
11111098 memcpy(term->baSourceID, &buffer[7], 1);
11121099
@@ -1125,10 +1112,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 12 unmodified lines
11251112 return -EINVAL;
11261113 }
11271114
1128− unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3],
1129− p + 1, 0);
1130− if (IS_ERR(unit))
1131− return PTR_ERR(unit);
1115+ unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0);
1116+ if (unit == NULL)
1117+ return -ENOMEM;
11321118
11331119 memcpy(unit->baSourceID, &buffer[5], p);
11341120
@@ -1148,9 +1134,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 13 unmodified lines
11481134 return -EINVAL;
11491135 }
11501136
1151− unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 2, n);
1152− if (IS_ERR(unit))
1153− return PTR_ERR(unit);
1137+ unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n);
1138+ if (unit == NULL)
1139+ return -ENOMEM;
11541140
11551141 memcpy(unit->baSourceID, &buffer[4], 1);
11561142 unit->processing.wMaxMultiplier =
@@ -1177,10 +1163,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 20 unmodified lines
11771163 return -EINVAL;
11781164 }
11791165
1180− unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3],
1181− p + 1, n);
1182− if (IS_ERR(unit))
1183− return PTR_ERR(unit);
1166+ unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n);
1167+ if (unit == NULL)
1168+ return -ENOMEM;
11841169
11851170 memcpy(unit->guid, &buffer[4], 16);
11861171 unit->extension.bNumControls = buffer[20];
@@ -1320,10 +1305,9 @@ static int uvc_gpio_parse(struct uvc_device *dev) · 133 unmodified lines
13201305 return dev_err_probe(&dev->intf->dev, irq,
13211306 "No IRQ for privacy GPIO\n");
13221307
1323− unit = uvc_alloc_new_entity(dev, UVC_EXT_GPIO_UNIT,
1324− UVC_EXT_GPIO_UNIT_ID, 0, 1);
1325− if (IS_ERR(unit))
1326− return PTR_ERR(unit);
1308+ unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1);
1309+ if (!unit)
1310+ return -ENOMEM;
13271311
13281312 unit->gpio.gpio_privacy = gpio_privacy;
13291313 unit->gpio.irq = irq;