Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5452281pxu; Tue, 22 Dec 2020 18:26:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKcO2I8nVbnxLObiQCFm1fXAXKxchjsoE8MMV7J/OdoPA4fPueY21WhjB66WRayQ/ZfQLG X-Received: by 2002:a17:906:1752:: with SMTP id d18mr22363209eje.529.1608690369520; Tue, 22 Dec 2020 18:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608690369; cv=none; d=google.com; s=arc-20160816; b=RRLfRQxi+BCLxNwcbx06vOeOdUSdAF0XnBR4OgOLordi/AU+HzDamt3HDsS/H4QDed xu+MhBzgEGEm+JTP8XOcltFqcB0HUt/hOaKEOP7pFEr1kmtYBVk7KKKAnMvKpTKUlH62 ajdmaNDU6/dEFHMleXFk+OGJnAZ38+Jbe3X7r0WedjiOofzhZxOi3DeOwba1CaECG4cN oD2xDxAgPQwhXLr9IseZyOIv3ZutxEj4vZ6+3Y1M3uWy199lDmtrLtMq8w1wqRwfF3fr xY3Wxfu9uZ5qbNn71t5VMMIO4mDHpBEySR8mG41x0h86TTZPboXjwYtiwCLfP30wgvjG UnIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YaXOUGIBIOa/fUcDQu+uO8VIcK1vGbrYuHWd7Xc5XSc=; b=0tl95zQNN0FBwhYi9rA6uHj4AN/3gWGCcyAOFWiszBG6dSap4guFGzjrpvTuooVXA7 kKWXxkhX35QB0rd2ZP5SXAhP00aenQ4vvRiiw27CnvlcTfwR+wFc9qcpGMgx0Mdh1M7z 8mFx/uBv7S3YzvnFJK/OeCpa8x/OBnNVCC4MZO9zKLE2JiqHtLs+Adw2GRAqb41e85/M e2v12n+wXHOiOyewvElhjNj4B1r1Y6sfea61wzg7W8psgqNfZYqDmfD9KJCskugGRkFH exXWmPBsfkFxtFAy0VVMX60e++TmbTCz1CzjHkfBDE/L4rBE5mJ9KIbCSsnno3mVH0kC KFRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mClP8FiC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f5si13174524eds.162.2020.12.22.18.25.47; Tue, 22 Dec 2020 18:26:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mClP8FiC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730117AbgLWCYC (ORCPT + 99 others); Tue, 22 Dec 2020 21:24:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:52686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730033AbgLWCXh (ORCPT ); Tue, 22 Dec 2020 21:23:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7294422A99; Wed, 23 Dec 2020 02:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690199; bh=emF2QKwDnHejaOpSs86sRk+/kZdCHjtSJ6FcUUjQrvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mClP8FiCav8rBehJWBDdleawUB61TCyq7Z2QucaOe0L1tkWMZjUNEtPGJ8uucmloN LmcwBcIf8ddEIuj91b6t/kJ0VmcpGnP9P7XYYHB5BN+xSITU80qxP0TrqFMtyRvFoa kyN5FjwomSL2ap4RUu6AoSo9iwpICsNplSSGXHlvvA0VmNVw2HEljTnQVLjEERJaGY LW1+IQNvcqBb4mHxzQBWYNRRtdtyX5XDbsrNLhisHiDTl5pCsjosudLltcEdHikguB nBc5JWlfvs76juNw3ihei1eWXJ7ViOoPMoK6tn1KaIGDSVssWFBDAgSjiu5q7IAmcA rH//35sJO/cnQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evgeny Novikov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-usb@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 21/66] media: zr364xx: propagate errors from zr364xx_start_readpipe() Date: Tue, 22 Dec 2020 21:22:07 -0500 Message-Id: <20201223022253.2793452-21-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Evgeny Novikov [ Upstream commit af0321a5be3e5647441eb6b79355beaa592df97a ] zr364xx_start_readpipe() can fail but callers do not care about that. This can result in various negative consequences. The patch adds missed error handling. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/zr364xx/zr364xx.c | 31 ++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c index d30f129a9db75..fe87e2159dae1 100644 --- a/drivers/media/usb/zr364xx/zr364xx.c +++ b/drivers/media/usb/zr364xx/zr364xx.c @@ -1352,6 +1352,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) { struct zr364xx_pipeinfo *pipe = cam->pipe; unsigned long i; + int err; DBG("board init: %p\n", cam); memset(pipe, 0, sizeof(*pipe)); @@ -1384,9 +1385,8 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) if (i == 0) { printk(KERN_INFO KBUILD_MODNAME ": out of memory. Aborting\n"); - kfree(cam->pipe->transfer_buffer); - cam->pipe->transfer_buffer = NULL; - return -ENOMEM; + err = -ENOMEM; + goto err_free; } else cam->buffer.dwFrames = i; @@ -1401,9 +1401,17 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) /*** end create system buffers ***/ /* start read pipe */ - zr364xx_start_readpipe(cam); + err = zr364xx_start_readpipe(cam); + if (err) + goto err_free; + DBG(": board initialized\n"); return 0; + +err_free: + kfree(cam->pipe->transfer_buffer); + cam->pipe->transfer_buffer = NULL; + return err; } static int zr364xx_probe(struct usb_interface *intf, @@ -1602,10 +1610,19 @@ static int zr364xx_resume(struct usb_interface *intf) if (!cam->was_streaming) return 0; - zr364xx_start_readpipe(cam); + res = zr364xx_start_readpipe(cam); + if (res) + return res; + res = zr364xx_prepare(cam); - if (!res) - zr364xx_start_acquire(cam); + if (res) + goto err_prepare; + + zr364xx_start_acquire(cam); + return 0; + +err_prepare: + zr364xx_stop_readpipe(cam); return res; } #endif -- 2.27.0