]> git.itanic.dy.fi Git - linux-stable/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 08:06:47 +0000 (10:06 +0200)
[ Upstream commit a7b2df76b42bdd026e3106cf2ba97db41345a177 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/pci/cx23885/cx23888-ir.c

index 040323b0f94557fce47419c6fd29a6e534addf04..f63a7e6f272c28853356f63a876fa1ceb0e317ef 100644 (file)
@@ -1178,8 +1178,11 @@ int cx23888_ir_probe(struct cx23885_dev *dev)
                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;
+       }
 
        state->dev = dev;
        sd = &state->sd;