chdev_driver: Avoid NULL pointer dereference when bch->refs == 255. From Juha Niskanen

This commit is contained in:
Gregory Nutt 2015-03-12 07:58:36 -06:00
parent 26b9b5a252
commit dba41a7048

View File

@ -307,7 +307,7 @@ static int bch_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
FAR struct bchlib_s **bchr = (FAR struct bchlib_s **)((uintptr_t)arg);
bchlib_semtake(bch);
if (!bchr && bch->refs < 255)
if (!bchr || bch->refs == MAX_OPENCNT)
{
ret = -EINVAL;
}