Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2996788imu; Mon, 19 Nov 2018 09:08:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/USU5+gzFbENE1IPcW9we9dINCyQxrKoq86u25X953NYbRILGj/C2ZMTC9AJYyggF9iL3AX X-Received: by 2002:a17:902:8e8a:: with SMTP id bg10mr10672513plb.192.1542647317715; Mon, 19 Nov 2018 09:08:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542647317; cv=none; d=google.com; s=arc-20160816; b=OQnFM6eV/+t6jei8vVfpPf7Dmy0MPq8VsMQXZkFmZwXFti4zfQC25tK4o0MoUGDp8K +HSq5x4bovQC8nuArCXBlixZbZ0acTuJNjxyyicX2fMqTQ75LCbv+vqVM5eJHs518LFc D2pVkkFvxr3udzZS6GNgxkots5/Ks9f1jTkEesYJTi8FYDP7felS3Y+javTyuLs7+OJI IlpiA5cmiw4vEKODLXqRlv1K00Jnltpthqx1yQii8sXXV0tWRiTgnq8U1hCbgAeBaO26 dILfGtJnBye/87dsNu5IfMnvH2/akCU4jjFBbjrv/SN403jbgiRJN3HvG+HHM7Iwx2XE roWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tkF5Sn4aAgfwJyRNzQmKg3FpXM4dPZBunLlR1b1Z7J4=; b=y1+bSyhSnSH1hpmvd49vXrVtRaRrUgFZtS1STto4TKdufsQQxXZAHSC3InCE+xXr6l GHJ34cGqayI/v/ECX9TbeHyswSQU+fsLstAL1djqJ0+rgeZkdmZwHqI0SyTpmS0jYKMM RVG+qXyNIG8HQaw4R1DCnH5tTERoVOJT3v0tNE7NiDHKW31IO77alv7gAEZFKf8wVrah XXZc4Ek40PyoeycwZ3KPUZNmQqIiChE03/VH7DsxA1511IpEjWf7gAmQcl+uYz22meoG Xh9kOroPwi27uA/HRBHG9cPMKG49y+McO+Le3ZSp3Rp5oCzhaJWLsnCmS6Rs6iy2cbiQ yepA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t9AMM0rX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si14616924plu.169.2018.11.19.09.08.20; Mon, 19 Nov 2018 09:08:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t9AMM0rX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406810AbeKTD3j (ORCPT + 99 others); Mon, 19 Nov 2018 22:29:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:44368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406762AbeKTD3i (ORCPT ); Mon, 19 Nov 2018 22:29:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9C87F214D9; Mon, 19 Nov 2018 17:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542647121; bh=ZO2c7TpVUlsGo+ptBSNO5fJxpU6K7kE0RhyKz5Bwqy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9AMM0rX0iO/cP4mscS9RNleiu6OXLOgKbv0jVsJ9Q6+p+5I42sP7KLdJv+IrjEMJ IJmj5cM95yHzRekGQ7NuyoRP6EzFOv4MqUDsh3qtUBaToCEWsh8DX4zPT0Ay72bUhN kVg/Bbl/e0QFB/W15iqNY62IambrUUesxUWUeh88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 3.18 57/90] media: pci: cx23885: handle adding to list failure Date: Mon, 19 Nov 2018 17:29:39 +0100 Message-Id: <20181119162630.015285457@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162620.585061184@linuxfoundation.org> References: <20181119162620.585061184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicholas Mc Guire [ Upstream commit c5d59528e24ad22500347b199d52b9368e686a42 ] altera_hw_filt_init() which calls append_internal() assumes that the node was successfully linked in while in fact it can silently fail. So the call-site needs to set return to -ENOMEM on append_internal() returning NULL and exit through the err path. Fixes: 349bcf02e361 ("[media] Altera FPGA based CI driver module") Signed-off-by: Nicholas Mc Guire Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/pci/cx23885/altera-ci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/media/pci/cx23885/altera-ci.c +++ b/drivers/media/pci/cx23885/altera-ci.c @@ -662,6 +662,10 @@ static int altera_hw_filt_init(struct al } temp_int = append_internal(inter); + if (!temp_int) { + ret = -ENOMEM; + goto err; + } inter->filts_used = 1; inter->dev = config->dev; inter->fpga_rw = config->fpga_rw; @@ -696,6 +700,7 @@ err: __func__, ret); kfree(pid_filt); + kfree(inter); return ret; } @@ -731,6 +736,10 @@ int altera_ci_init(struct altera_ci_conf } temp_int = append_internal(inter); + if (!temp_int) { + ret = -ENOMEM; + goto err; + } inter->cis_used = 1; inter->dev = config->dev; inter->fpga_rw = config->fpga_rw; @@ -799,6 +808,7 @@ err: ci_dbg_print("%s: Cannot initialize CI: Error %d.\n", __func__, ret); kfree(state); + kfree(inter); return ret; }