Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2724156imj; Mon, 11 Feb 2019 07:32:35 -0800 (PST) X-Google-Smtp-Source: AHgI3Iak7woDbtDJV1s6/GRgtnRIk/9B5Dg+hpRK61fKCVY4XPMynZiUdI4gPOQHHUNyuvaxx3CO X-Received: by 2002:a17:902:d01:: with SMTP id 1mr38532841plu.127.1549899155239; Mon, 11 Feb 2019 07:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899155; cv=none; d=google.com; s=arc-20160816; b=gZONX2DaBrNP3PIo4r3ujPvG22qEtti5eXhuDK9U9QUhIIfCff37SMuHxh9bMtHAzd yFGv/rYmCl4LS2eO4YuLL0qrWLr67ymFaY1c6dKLfdYcVCOfBCFRz40DvHXHcC3H9FOz iwZdkTsvSqumOR651aM1R0pBnFJ6eqvx91NX57PnrtHShXRThzZBrkXwkJbsWuDtg7/Z yYcs73tysiuOchY+na4PyZ44hQeGzZQeHLadROPoCAIX/v+tVW1bs0eu1gWkACylmluU 5y8q2QkHBuOPj7UQmVR8x3uzR7QIHyzv45OpMiQcgmQgxiQb/mxqScOqOveLR34QuR2r +3+Q== 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=SpJ2JVshp4B9sWonMnnMhP6sJGC/M2Cs3uDKU284o+8=; b=Db+8QFrckqPzQbowWi5sB2rDSSDTLXLyIPE4pBL67KPU5TRYUEv3UA/p6QalTcyNvn bpjB6QC4emCRrHT7/5lXmsLtSVtbWnyM4ge65/Qnm02SDRG3wAdDIpLZ+/YDxEoIDh4h poNppVCQtH44KOyfNzHjpGidGTLYIgjsANCvDvlOu+20DvjrS2gbjMUYc6WChESRojzY dvtSAX7D57fYD2f0IQtZf5nfW0sEe4aeS3fUASfRoLQ8rEXl62mbqoAjLI1I38qG6w6e VL95uInCnXoaH7wILdXVtFD4cnX4Ns2Ox/1PvmBtH9U/vhuPxo1BdAlrmuwiXGdaZwqB 1M0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GvxJR47u; 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 s73si10003816pfs.54.2019.02.11.07.32.18; Mon, 11 Feb 2019 07:32:35 -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=GvxJR47u; 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 S2389236AbfBKO4r (ORCPT + 99 others); Mon, 11 Feb 2019 09:56:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:44018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388720AbfBKO4p (ORCPT ); Mon, 11 Feb 2019 09:56:45 -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 24F44222A6; Mon, 11 Feb 2019 14:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897004; bh=Zj2DHOpdqQY4xH6knWsKWdJdJP13iv1HURZUA4v0Ayg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GvxJR47uive2NRZ0VEwOUlSOrunY+k+/gWgFNB0N36cFy71TyN+gmEAvCW8xOr4X3 U6rrbdgwf9Dhsn3nDQs8P6wP5UMmoWOajnbFzbGv2bNNbqhJspKsNePbTUJKNipsOP sx2277jSYokR8vPzQJINjvItO4JuU+ZbD1Oq3QqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Khoroshilov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 060/205] media: DaVinci-VPBE: fix error handling in vpbe_initialize() Date: Mon, 11 Feb 2019 15:17:38 +0100 Message-Id: <20190211141832.732693973@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit aa35dc3c71950e3fec3e230c06c27c0fbd0067f8 ] If vpbe_set_default_output() or vpbe_set_default_mode() fails, vpbe_initialize() returns error code without releasing resources. The patch adds error handling for that case. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/davinci/vpbe.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c index 7f6462562579..1d3c13e36904 100644 --- a/drivers/media/platform/davinci/vpbe.c +++ b/drivers/media/platform/davinci/vpbe.c @@ -739,7 +739,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) if (ret) { v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s", def_output); - return ret; + goto fail_kfree_amp; } printk(KERN_NOTICE "Setting default mode to %s\n", def_mode); @@ -747,12 +747,15 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) if (ret) { v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s", def_mode); - return ret; + goto fail_kfree_amp; } vpbe_dev->initialized = 1; /* TBD handling of bootargs for default output and mode */ return 0; +fail_kfree_amp: + mutex_lock(&vpbe_dev->lock); + kfree(vpbe_dev->amp); fail_kfree_encoders: kfree(vpbe_dev->encoders); fail_dev_unregister: -- 2.19.1