Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2904262pxb; Tue, 24 Aug 2021 10:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgSuSaLKQXzg2uLfvJbUBvY52nSD1hTlajacSjQXOI5XzyI1XDCD/xiX4EK2LQnJ8EeJZO X-Received: by 2002:a02:c61a:: with SMTP id i26mr36260031jan.108.1629825344344; Tue, 24 Aug 2021 10:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825344; cv=none; d=google.com; s=arc-20160816; b=M4v0zWflnUAeh2Z6CN1wONhkJRuPtDvZFhiB1X4OfT1BD8YBanh22SWZdBGPcO3EzE E4fHUJ/LLbFd0FT1MapX7p35v+XdwFrGU1N3h5kQ/4ajFuMU+RAmj/U+vhC9u4hv+rG9 ZP+eft779WIvECRIbSIOWysBsBZ0igs2cBcZ6iGyDnzYT1w57pTeNzWOeXZO7fQwWDaw 9TMEP5COHXwXc29eGxhULRv405CBUxQ8k6qUXOz/aJcpGMtXpABzjmKrRo0q7hNcdblF 87R08OUYVlVdGmDQ6m5IjvmQ3FK+m7c04CJLdG/VZ+aDnh8SwvoUTdNmK6yrgHeh3ygY dv1w== 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=1Slk7nB3GK5CyVwrEwi/4F/D1h8QBEdSiYHoVBCgBSk=; b=HKivwP52rrAMJwAvDJ5OpnrGiAiLHkBepcOSnGeZi3dij8cHyaCg76M1bHOsN0kLtu DswgNp+Qleyhzdosm71axCFpMTL4tFtAbPZV4rBFV4/njaxu08EKdMc/buMzyEb75Ctf KFU8dmGufrqyy1ez1/e+DzuVju9Lw8m1pI2i7xgsPOyWRXdI7MFykT3lHGcd/tMIt2nB IcZ7OnE6vYGqSP7ERG0M35/a9AMjpHC51f88c8sREaDijZSfwHI4LV605toGk8XEp38k vAK+1w3+GY+D4yQw1fymhkDAkzkwZ0USuFdi5mWxIG+zD4+cgd/6PcDh90w8z7Gcbsk3 3AnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mHBN1LZ/"; 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 d4si18473260jak.4.2021.08.24.10.15.31; Tue, 24 Aug 2021 10:15:44 -0700 (PDT) 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="mHBN1LZ/"; 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 S239550AbhHXRPf (ORCPT + 99 others); Tue, 24 Aug 2021 13:15:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:52050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239598AbhHXRMD (ORCPT ); Tue, 24 Aug 2021 13:12:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6B546127B; Tue, 24 Aug 2021 17:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824477; bh=cwUrmVyOSUBhwTQWvfLxuyLUHzKvEJK2Gfu7ZqeYEhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mHBN1LZ/bugZRGXwZpf1XSOhIAJs6LtGi344wCCgBzggDriwKB6CeNLiAoUqIXa+j BBW1CQhFjfMzyNjvGtcwOUxq0O0cJvgD9AARiCuxx4+celza9g3Rsu2swdCpCAiaTK Mqh2//BCLBQnInJxX6EjuTS3EAqwMmaFogVluIyhBJ0KE791YE7nkcJ4SEYixhm3B0 Wv5ePN9bSPu+95ny9ByE1RTqiU/+nLEsQ3J4c9VzR1zS33CzYdKlnpre8SwtdnYts2 Qi/RhAqx51dA6Ia+n75miPro20xUHz6HSWFJtHyzwjbzuiaYkKmUZtQQWdmNG6VgsN /PVviNFI/vDww== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evgeny Novikov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 09/61] media: zr364xx: propagate errors from zr364xx_start_readpipe() Date: Tue, 24 Aug 2021 13:00:14 -0400 Message-Id: <20210824170106.710221-10-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170106.710221-1-sashal@kernel.org> References: <20210824170106.710221-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.143-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.4.143-rc1 X-KernelTest-Deadline: 2021-08-26T17:01+00:00 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 02458c9cb5dc..22b34690a016 100644 --- a/drivers/media/usb/zr364xx/zr364xx.c +++ b/drivers/media/usb/zr364xx/zr364xx.c @@ -1331,6 +1331,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)); @@ -1363,9 +1364,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; @@ -1380,9 +1380,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, @@ -1579,10 +1587,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.30.2