[media] v4l2-dev: don't memset video_device.dev

Zeroing video_device.dev causes a memory leak if video_set_drvdata
was called before video_register_device was called. video_set_drvdata
calls dev_set_drvdata which allocates video_device.dev.p.

memsetting this will prevent freeing of that memory.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by Hans Verkuil and committed by Mauro Carvalho Chehab 46b63377 6ce3ced4

+4 -5
+4 -5
drivers/media/video/v4l2-dev.c
··· 419 419 * The registration code assigns minor numbers and device node numbers 420 420 * based on the requested type and registers the new device node with 421 421 * the kernel. 422 + * 423 + * This function assumes that struct video_device was zeroed when it 424 + * was allocated and does not contain any stale date. 425 + * 422 426 * An error is returned if no free minor or device node number could be 423 427 * found, or if the registration of the device node failed. 424 428 * ··· 444 440 int minor_offset = 0; 445 441 int minor_cnt = VIDEO_NUM_DEVICES; 446 442 const char *name_base; 447 - void *priv = vdev->dev.p; 448 443 449 444 /* A minor value of -1 marks this video device as never 450 445 having been registered */ ··· 562 559 } 563 560 564 561 /* Part 4: register the device with sysfs */ 565 - memset(&vdev->dev, 0, sizeof(vdev->dev)); 566 - /* The memset above cleared the device's device_private, so 567 - put back the copy we made earlier. */ 568 - vdev->dev.p = priv; 569 562 vdev->dev.class = &video_class; 570 563 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); 571 564 if (vdev->parent)