imperfectism / rpms / kernel

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