Skip to content

Commit

Permalink
[media] media: Fix media device minor registration
Browse files Browse the repository at this point in the history
The find_next_zero_bit() is called with the from and to arguments in the
wrong order. This results in the function always returning 0, and all
media devices being registered with minor 0. Furthermore, mdev->minor is
then used before being assigned with the find_next_zero_bit() return
value. This really makes sure we'll always use minor 0.

Fix this and let the system support more than one media device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Jun 1, 2011
1 parent 67e27c7 commit 8c89ddd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/media-devnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ int __must_check media_devnode_register(struct media_devnode *mdev)

/* Part 1: Find a free minor number */
mutex_lock(&media_devnode_lock);
minor = find_next_zero_bit(media_devnode_nums, 0, MEDIA_NUM_DEVICES);
minor = find_next_zero_bit(media_devnode_nums, MEDIA_NUM_DEVICES, 0);
if (minor == MEDIA_NUM_DEVICES) {
mutex_unlock(&media_devnode_lock);
printk(KERN_ERR "could not get a free minor\n");
return -ENFILE;
}

set_bit(mdev->minor, media_devnode_nums);
set_bit(minor, media_devnode_nums);
mutex_unlock(&media_devnode_lock);

mdev->minor = minor;
Expand Down

0 comments on commit 8c89ddd

Please sign in to comment.