Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1593231imd; Sun, 4 Nov 2018 06:00:58 -0800 (PST) X-Google-Smtp-Source: AJdET5cKKogPMsqwIxEeGhELlUfFK7DSNVnGo8JslWVOH/nkl3nw8EAibavi9x2AaWJgAfdOAWle X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr18956420plt.34.1541340058585; Sun, 04 Nov 2018 06:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340058; cv=none; d=google.com; s=arc-20160816; b=jkb24+yvKHAUzT1eyd7tXiG++NMEbXyXhlXipurN47lneOEvtvZ8OyM5k+O3dfe/eT yha2+R7NVyDtQjrBJAbKNJ7YB5yHpwduM3e6MbgUETttxIE98AS5jcLTPHPHAlR1e0P/ IKQn97L7oqOBtmvU0QzXY+jp7XJz+tOzoRR3MnUOH1SF5wN0w8gGr5begOj15eVtUi5Z oJY0XH8lifyoz9KrjkwMGLzrGsTDQ/nYMspfmrkAzn7w0gbSKhaSONmc7MtK3CR3pUIz C/fFPLKK/T2TY8GE0re3W7QT61S+lcNjirfGP2j58iJ9EnYfcUcqeJt8n8LylqFE3SMu yPDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=vQo6raps4nfwhTxcDuT0+AUfyDHh4s12LiseH3PZAp8=; b=c2/monAuEL+H67UrFnPtkumkZER9qjAvmJkuIKECqfnoAyJ5xIww8XDFsWKS2C96lJ xe1J3icCJU/PAKOqgMFon6tmYYpuUbIVaLDMueWFyA2wKATYkNOM0uHBJ9eqYaSJh3oW FGCGAGQb/YVrXEBeRggg+SkmdRMwTNcboIdxSicgOWU/ithZ9Kjcd1s8imIgS6CFu3ME 6htObp1LmDEcW7FX2ttcQwUhUMQr35/QykoEdkPgJywjLO60m2F/Lv3G4yzg5kn/fTIa Vi6qPorQlFdDb1JEmggeTbzKGXmgeGLNbvFVCoJi9FcArrDQXWi3RgVTcsU+rxPl0NGV 0u8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XaOrkKVS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si15145670pgs.31.2018.11.04.06.00.43; Sun, 04 Nov 2018 06:00:58 -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=XaOrkKVS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731319AbeKDXIt (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:47906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731298AbeKDXIs (ORCPT ); Sun, 4 Nov 2018 18:08:48 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7076A20866; Sun, 4 Nov 2018 13:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339624; bh=omP8rgVRu6+n4g4OBhgNDlgrp0ssFhH+WT5qRxbbD30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XaOrkKVS0bGSo+tlycLWQ+Nuj8U2i/MmowZBA0vkdCZ1+ocVoScuHIPdJePKfMpQ4 OXV4auRgJ9dKhlwzhGmTTlxdyIRtm83hYsJccBW6DvjbBB6atqtBj675eFJgIYN+xw JHzJexPh+UuCykEH/6HyQR/OzwQXukJ0JxToj6jM= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nicholas Mc Guire , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH AUTOSEL 4.14 18/30] media: pci: cx23885: handle adding to list failure Date: Sun, 4 Nov 2018 08:53:13 -0500 Message-Id: <20181104135325.88524-18-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/media/pci/cx23885/altera-ci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/pci/cx23885/altera-ci.c b/drivers/media/pci/cx23885/altera-ci.c index 5c94e312cba3..f77254cc16bf 100644 --- a/drivers/media/pci/cx23885/altera-ci.c +++ b/drivers/media/pci/cx23885/altera-ci.c @@ -665,6 +665,10 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr) } 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; @@ -699,6 +703,7 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr) __func__, ret); kfree(pid_filt); + kfree(inter); return ret; } @@ -733,6 +738,10 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr) } 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; @@ -801,6 +810,7 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr) ci_dbg_print("%s: Cannot initialize CI: Error %d.\n", __func__, ret); kfree(state); + kfree(inter); return ret; } -- 2.17.1