From dba41a704879bf22fab57a2634d5f15b49512364 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 12 Mar 2015 07:58:36 -0600 Subject: [PATCH] chdev_driver: Avoid NULL pointer dereference when bch->refs == 255. From Juha Niskanen --- drivers/bch/bchdev_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c index 7e3d2abcb3..d1a23c554f 100644 --- a/drivers/bch/bchdev_driver.c +++ b/drivers/bch/bchdev_driver.c @@ -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; }