a1f67e6
From patchwork Wed Sep 25 15:02:41 2019
a1f67e6
Content-Type: text/plain; charset="utf-8"
a1f67e6
MIME-Version: 1.0
a1f67e6
Content-Transfer-Encoding: 7bit
a1f67e6
X-Patchwork-Submitter: Navid Emamdoost <navid.emamdoost@gmail.com>
a1f67e6
X-Patchwork-Id: 1131334
a1f67e6
Return-Path: <SRS0=wETr=XU=vger.kernel.org=linux-kernel-owner@kernel.org>
a1f67e6
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
a1f67e6
	by smtp.lore.kernel.org (Postfix) with ESMTP id D12E6C432C2
a1f67e6
	for <linux-kernel@archiver.kernel.org>; Wed, 25 Sep 2019 15:02:56 +0000 (UTC)
a1f67e6
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
a1f67e6
	by mail.kernel.org (Postfix) with ESMTP id A3ACD21D7B
a1f67e6
	for <linux-kernel@archiver.kernel.org>; Wed, 25 Sep 2019 15:02:56 +0000 (UTC)
a1f67e6
Authentication-Results: mail.kernel.org;
a1f67e6
	dkim=fail reason="signature verification failed" (2048-bit key)
a1f67e6
 header.d=gmail.com header.i=@gmail.com header.b="arASj5Yv"
a1f67e6
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
a1f67e6
        id S2438783AbfIYPC4 (ORCPT
a1f67e6
        <rfc822;linux-kernel@archiver.kernel.org>);
a1f67e6
        Wed, 25 Sep 2019 11:02:56 -0400
a1f67e6
Received: from mail-io1-f66.google.com ([209.85.166.66]:44698 "EHLO
a1f67e6
        mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
a1f67e6
        with ESMTP id S1731142AbfIYPCz (ORCPT
a1f67e6
        <rfc822;linux-kernel@vger.kernel.org>);
a1f67e6
        Wed, 25 Sep 2019 11:02:55 -0400
a1f67e6
Received: by mail-io1-f66.google.com with SMTP id j4so14606376iog.11;
a1f67e6
        Wed, 25 Sep 2019 08:02:53 -0700 (PDT)
a1f67e6
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
a1f67e6
        d=gmail.com; s=20161025;
a1f67e6
        h=from:to:cc:subject:date:message-id;
a1f67e6
        bh=MWyh3PNmOklfeVqzYOrNwzDcAH8lax2jMCGmRDG4urM=;
a1f67e6
        b=arASj5Yv5bqz17U8QZVYbble7TDB5sj0TMbNk56fxz5ejOoHyT3kYbYJ/QtfbbLSs6
a1f67e6
         iEjbcUYxhDqPRDkxpycr9uysp4vVx+usX4dONocnmhwJEwUZNwBO9gxatNe8zkYv3cBV
a1f67e6
         6/zgf3/mu1ElXkjkjabewFHnWgFLNY2bEKtd9Wx3P6FGJyuwNg5dgB8SDQb/2DSr4X9q
a1f67e6
         aUgMqjBas1yw+cOjn/+KzpYS5k6gjQTDGNc4k+SZec43+S+O208YvxdUJ1ivWceNMa90
a1f67e6
         RFPA3kk2XYQIgbJVbmqVTOzfX1l/qDVCb/GHdWaEq3GUolGoF7RGnD3ntqNF7uyElR4g
a1f67e6
         1cfA==
a1f67e6
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
a1f67e6
        d=1e100.net; s=20161025;
a1f67e6
        h=x-gm-message-state:from:to:cc:subject:date:message-id;
a1f67e6
        bh=MWyh3PNmOklfeVqzYOrNwzDcAH8lax2jMCGmRDG4urM=;
a1f67e6
        b=a11vAjMQ8OwRtbrsNLlkXz9P6ewInEp9Y3Yp+tDjNcUdkcFEfckW79Eoc5EIFPd58E
a1f67e6
         KdJncVKoKTHG4PNxbHcjBXFY82d8wYP+gzkfv4Fx5zKfi9ZRj03gupr1tq8kAizI6+QM
a1f67e6
         fQUaDU5Z+kETTNPQx4V9W9WsMituZTsmC3yIjhtyaY9qnvDFpjeIcFi8ityCJ59nqaBs
a1f67e6
         xDkYx9NCUK/ZkRujeIznZ3kaCDvgTxG/PM02POWE8/CEnkaS4oVwMqIJ1WJqRO4cW5Rd
a1f67e6
         ak9LLUKankinb6T5dd1BPeVmOq4MJJnB8OrnMrENhtYgLgCDELF9090hqfpBkv4FW4zN
a1f67e6
         vGOQ==
a1f67e6
X-Gm-Message-State: APjAAAULnVDgP2mQfcWBZXj8JYWYlmhlw/fk0WqZRMbvjRR4s+BO+yLW
a1f67e6
        YtHDvZSJqP12YLMYI6zTrm0=
a1f67e6
X-Google-Smtp-Source: 
a1f67e6
 APXvYqwPBH16FuEXUH7rOy3JWTXRjXFzwF9Spfa1QHh9p2MfWd+kBFJthLybBlVk8lVb6Ym4UWB2NA==
a1f67e6
X-Received: by 2002:a5d:8ad4:: with SMTP id e20mr2109019iot.203.1569423773435;
a1f67e6
        Wed, 25 Sep 2019 08:02:53 -0700 (PDT)
a1f67e6
Received: from cs-dulles.cs.umn.edu (cs-dulles.cs.umn.edu. [128.101.35.54])
a1f67e6
        by smtp.googlemail.com with ESMTPSA id
a1f67e6
 2sm206447ilw.50.2019.09.25.08.02.52
a1f67e6
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
a1f67e6
        Wed, 25 Sep 2019 08:02:52 -0700 (PDT)
a1f67e6
From: Navid Emamdoost <navid.emamdoost@gmail.com>
a1f67e6
Cc: emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu,
a1f67e6
        Navid Emamdoost <navid.emamdoost@gmail.com>,
a1f67e6
        Mauro Carvalho Chehab <mchehab@kernel.org>,
a1f67e6
        Kate Stewart <kstewart@linuxfoundation.org>,
a1f67e6
        Thomas Gleixner <tglx@linutronix.de>,
a1f67e6
        Allison Randal <allison@lohutok.net>,
a1f67e6
        Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
a1f67e6
        Sean Young <sean@mess.org>, linux-media@vger.kernel.org,
a1f67e6
        linux-kernel@vger.kernel.org
a1f67e6
Subject: [PATCH] media: rc: prevent memory leak in cx23888_ir_probe
a1f67e6
Date: Wed, 25 Sep 2019 10:02:41 -0500
a1f67e6
Message-Id: <20190925150244.13644-1-navid.emamdoost@gmail.com>
a1f67e6
X-Mailer: git-send-email 2.17.1
a1f67e6
To: unlisted-recipients:; (no To-header on input)
a1f67e6
Sender: linux-kernel-owner@vger.kernel.org
a1f67e6
Precedence: bulk
a1f67e6
List-ID: <linux-kernel.vger.kernel.org>
a1f67e6
X-Mailing-List: linux-kernel@vger.kernel.org
a1f67e6
a1f67e6
In cx23888_ir_probe if kfifo_alloc fails the allocated memory for state
a1f67e6
should be released.
a1f67e6
a1f67e6
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
a1f67e6
---
a1f67e6
 drivers/media/pci/cx23885/cx23888-ir.c | 5 ++++-
a1f67e6
 1 file changed, 4 insertions(+), 1 deletion(-)
a1f67e6
a1f67e6
diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c
a1f67e6
index e880afe37f15..90e7c32c54bb 100644
a1f67e6
--- a/drivers/media/pci/cx23885/cx23888-ir.c
a1f67e6
+++ b/drivers/media/pci/cx23885/cx23888-ir.c
a1f67e6
@@ -1167,8 +1167,11 @@ int cx23888_ir_probe(struct cx23885_dev *dev)
a1f67e6
 		return -ENOMEM;
a1f67e6
 
a1f67e6
 	spin_lock_init(&state->rx_kfifo_lock);
a1f67e6
-	if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
a1f67e6
+	if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE,
a1f67e6
+			GFP_KERNEL)) {
a1f67e6
+		kfree(state);
a1f67e6
 		return -ENOMEM;
a1f67e6
+	}
a1f67e6
 
a1f67e6
 	state->dev = dev;
a1f67e6
 	sd = &state->sd;