media: rc: prevent memory leak in cx23888_ir_probe
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Wed, 25 Sep 2019 15:02:41 +0000 (12:02 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 7 Oct 2019 10:44:16 +0000 (07:44 -0300)
In cx23888_ir_probe if kfifo_alloc fails the allocated memory for state
should be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/pci/cx23885/cx23888-ir.c

index e880afe37f1515d554d23aa4ebeb2ded0215703f..d59ca3601785ef05784f4255edd35eaea920cbed 100644 (file)
@@ -1167,8 +1167,11 @@ int cx23888_ir_probe(struct cx23885_dev *dev)
                return -ENOMEM;
 
        spin_lock_init(&state->rx_kfifo_lock);
                return -ENOMEM;
 
        spin_lock_init(&state->rx_kfifo_lock);
-       if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
+       if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE,
+                       GFP_KERNEL)) {
+               kfree(state);
                return -ENOMEM;
                return -ENOMEM;
+       }
 
        state->dev = dev;
        sd = &state->sd;
 
        state->dev = dev;
        sd = &state->sd;