Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2767263imj; Mon, 11 Feb 2019 08:10:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IYTf/WeqaONL6gsvY1cVR/GJGeOoMqFRzP14rfwNT1au49jFihN8QqYIhvDNr2iLoqtW7fT X-Received: by 2002:a63:101:: with SMTP id 1mr34183023pgb.152.1549901414815; Mon, 11 Feb 2019 08:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901414; cv=none; d=google.com; s=arc-20160816; b=nLrS4LJeTWMvaHnxOo7gVvq9jf458oN68o24Fn6FbtDi3sgs5er76Q9iPxrqHaclH+ 1CHsHCNtnP72mOJDuwA5JiOdkIxUb4Wd3e9oensu8X/j+VPa1RfF4MYZ5Fu+JEc56ANx Gn0gec+oBJ4TMVYOpIAM0bs2QnpeX7TCIaaoWgrh8oPUwsxCxO81laKnhGPxjwbwJCOn pH5fz6EeMI3swsuygGcyaXjZk7OjVKOTXOXF6+WbguSfAUxfe87eM6o4j/i2GjGa0uv1 nsUezXJB5ASeQ0C6naohmrcrUOuOLGgFXI+3ZPR63y7Gwny8NQiRaqdE+FiMuBIMEF4i EbNg== 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=1dJRGXPueeGvI9FIPXEQKkw29Zk+Uf1wRoglT7Nb7fw=; b=LjTVfZuh7lqXhrsrH/9/upnBKw6YdvFvwmF1vRoArxKwjmiPhYvbfDQ1IY16C8gSZp ETY0X/NRdSqQEs0VGxymL6e2b+LRnKhgwCrox1/k5A597IEu71GHnXhZ/nHE0C/0qQGY fhlhaIYChNwJXEdwaBk2QiiNpqSfnfL78+oxkFMqhSJtAPEhAcDmqyHf3fikxdVfvX4Z KLX2ijv4mGnRrESUNq39krILJ2qDT9SkfXxYImEOa8hvnjb60cq8Jv1PkSrEy2rcsyWx 5PXUAaYtjDUCWSODPr9/XkFayDWdmKCbe6DJW3AMqgxii2ivzM7D7KtTAMoB1rcKN0+S tRtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tZ6xVmt6; 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 z5si9462025pgu.19.2019.02.11.08.09.59; Mon, 11 Feb 2019 08:10:14 -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=tZ6xVmt6; 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 S1727451AbfBKQJA (ORCPT + 99 others); Mon, 11 Feb 2019 11:09:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:59360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729425AbfBKOZp (ORCPT ); Mon, 11 Feb 2019 09:25: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 7885320821; Mon, 11 Feb 2019 14:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895144; bh=qx4hahrax8tBrxETbcVO7VUaMjKq/sFlO+ix9E28xE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZ6xVmt6eCAurW/iyHwl6eyYoHFUo3WOKIvK1PRzr5b61ytiKHfKH1e4Af0VFrwl8 zFFpDY+O/App0tnUDW4uW89WMDAiAVbJV6K1ebspU/War4FPgHcuyaX2mlVJopuUCH MPRc7/ARP0wKQGryForQoELp/5DFheBda42enDPs= 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.20 106/352] media: DaVinci-VPBE: fix error handling in vpbe_initialize() Date: Mon, 11 Feb 2019 15:15:33 +0100 Message-Id: <20190211141852.529609218@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 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