Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3707933imu; Mon, 28 Jan 2019 09:23:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN4M87k8aw1JdEf7jXFpyrUSdEGHFjhzYNexDMuiV+4yOggfUzJzyr9BRP3b4aCD7zzSmBIz X-Received: by 2002:a17:902:6acc:: with SMTP id i12mr22059999plt.148.1548696195576; Mon, 28 Jan 2019 09:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696195; cv=none; d=google.com; s=arc-20160816; b=Z+bFewi6lsRglSVE0YpsSHIOwcnHLmxhkadLj4Rt4LXQbJKangITQMoSG77CC+ZPa2 xnKlGUkVYft03Rb+AQ52xhpusAjCKTT2WOtlzaqUgVnZIb6BjjAVUss8lbZjatHeM0UO ISTK53RDRqKR/cBuZ5PbmnzPqHX6T70JEWxkhmdyQCBfEGZVLr0sAQlOp+vFLIHQJ51d nJPHswurwc+HKnCQKajmUoOLgZm2sFxY2p45le+Df+HhQxU8cxev+JMb6hDc5oPp2Mxv 5Y3PayFp5VPYkXPcJryiRCTnKJ0sNkk8ZsmNpMVGB3LU9/Bm7xViOjpFoeeNmQ/Ws/iX Xe6g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X/o5Qhs5wFaBi5e60P6IxZZ1RHEtZS2FVUFH9B08KuM=; b=H9+qnz/VZZvdt6apMeL3MeDckHnufYfMCNVerubYNlq/lUt5wEdY3mBTASFicVy/5A vMkz/RAavqvNq/WP/KeDnhUo5H2C39Ao8/7dOTNp6CuIp/I3Fpf5ULq+islm4E+95pCE So8vj/gHOnhQVhpKjVuQ5okyj95eGa2XYUYxSGJeyPxWWzE7rddRX05KnKg4KmGaZEC6 vTRBS6uz9i5Q6+zQ5bK0OecQXs7JxvWtc1C61CCJN2/o3ljUv8rj1RmBrwMWDjOtEGiA o/am6wJX2HH3USGWBR2R5U2PswrWtwMx6AobhcZEfkeN2/+e/U/kyz3xpo83P4NBLcBh jZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ITYVip8l; 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 135si32527107pge.572.2019.01.28.09.23.00; Mon, 28 Jan 2019 09:23:15 -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=ITYVip8l; 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 S1731468AbfA1RUu (ORCPT + 99 others); Mon, 28 Jan 2019 12:20:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:49788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbfA1QET (ORCPT ); Mon, 28 Jan 2019 11:04:19 -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 37C632175B; Mon, 28 Jan 2019 16:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691459; bh=GimJwDBZPDcf6I0LyCLPvuyGUj5ppxJl4VF6fyJOwPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ITYVip8lh/bCA8s6kz5MCe1OBo7196kYEhYAoSp/Qxo1vXerB8yLC8XrV0LvLOM91 mJPkDrPPFZxGaK5gIKPP9woYy6sh2EXwBwifd8FcNfVfqCb6uEfrH0gBEA69nl3wPY KlSchzWazbt1CAaL6p3xRULyucH5wRRYZSDffRWU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexey Khoroshilov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 099/258] media: DaVinci-VPBE: fix error handling in vpbe_initialize() Date: Mon, 28 Jan 2019 10:56:45 -0500 Message-Id: <20190128155924.51521-99-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Khoroshilov [ 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 18c035ef84cf..df1ae6b5c854 100644 --- a/drivers/media/platform/davinci/vpbe.c +++ b/drivers/media/platform/davinci/vpbe.c @@ -740,7 +740,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); @@ -748,12 +748,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