Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2897679pxb; Tue, 24 Aug 2021 10:07:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq2rmSVG7gVhRvU2tnulzQw59/zMzjbWUfyJX2saLgdFRKBqywkUiF5Vb9GqzPIK+g3b4S X-Received: by 2002:a05:6e02:1b05:: with SMTP id i5mr13337015ilv.5.1629824836449; Tue, 24 Aug 2021 10:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824836; cv=none; d=google.com; s=arc-20160816; b=RAjEHrnoHF00j1CW5cQjmQrysX0obdiPQogYYgRPvhGOno+6d0QukZ6YrHoLduQLFo 11qi+1e+6wjE6kAsYRWWIrXC2Tecp2Tm6ITPzx6ozIM7v0D9e4vgXObPDWl+Nugv66MC B0PdHmInAqMVaYv7yHcRmMFV/cHkCxD1aR2abUf4P1n3qxMO6sNLgT5LcFY8tMteiND1 OAhChLFUXelj0SUQx09FtwKRQsPOSoHMAWETf6NJvJOlDZejCDf24TcDHix0lKgJTF2O aC1YyZpqV2x0TXqBVIpCuckBnuFAIejDaI/oE4tW/Sn00v4E38eqBGzmor17VsHt8VJ1 GPBg== 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=S1MeWPXGo0V81qEc8x8392H7XLk7XMKeAS/+NM1j9YE=; b=TDWuYo+KVRgLReb4lxgxR2Fpsw17AZKoDx9fb3YTEbn58ue6EXCm0fLNsNM3zzI7VX 5kmb8AyMjd5E1UZxNecEGIq/7t4nfaTbZjxUIyAprgz9fdx4Dp3IaYZJNtjrl/Q69H7Z 9Mp3+sBiKmJRLypekc5L1/eqoIOg7mUmimippLdJnei6W9OsNSbYCIwzPCEUzoZFuOpp QSXvOM6s2uDmA9F5xhEz4eBI4Ui11ZAK6FdDSZBpcXHIR5rL4+e216A3r28vnlrXlMlC l2PICPnONjSBy+E/Hf178MSzMFyhxDd7MX883xPQ3VhF+R7No5/nObhKyNKzKPSaKdAG YJLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QaPONsoI; 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 p14si18229609jas.66.2021.08.24.10.07.03; Tue, 24 Aug 2021 10:07:16 -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=QaPONsoI; 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 S239055AbhHXRFe (ORCPT + 99 others); Tue, 24 Aug 2021 13:05:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238829AbhHXRDM (ORCPT ); Tue, 24 Aug 2021 13:03:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFE5661411; Tue, 24 Aug 2021 16:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824357; bh=lew2ynpmJL88exa4duwv1lrXEiKNV2KzqcEFKUa/Y+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QaPONsoIfptKTD0nEkf0lITPXeztY5EReRxV3cunLiIWqPna6kyGK8HaUigkrMqbD u+f4cuNpuu60AYVFgxv6mzBiyP2IRW1MMoWvbqlw2Jr2ZbxwL/1Xb8s+bIwBG0J2jV G1zZu0FBLvdhyRt7+TJOFq6xLWyGBPdJNKBAVEHV1cUuTKG0wKbP+4Jt5J+ESIdr/O KBvqXQyy3fBgToJMMZz5JmTzi4WpprELSKXtfmZYInbhE9COh0u9NoYB6jTO4IHwxT XNb6Blq7GZhzvLTCg6QFyB7k1fTIWlvRMW2JHUBfIo4IfywoUHLub3b4cGHZJafzdy hNLEbRSWXb8gQ== 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.10 07/98] media: zr364xx: propagate errors from zr364xx_start_readpipe() Date: Tue, 24 Aug 2021 12:57:37 -0400 Message-Id: <20210824165908.709932-8-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165908.709932-1-sashal@kernel.org> References: <20210824165908.709932-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.61-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.61-rc1 X-KernelTest-Deadline: 2021-08-26T16:58+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 1b79053b2a05..5c8997d7de23 100644 --- a/drivers/media/usb/zr364xx/zr364xx.c +++ b/drivers/media/usb/zr364xx/zr364xx.c @@ -1328,6 +1328,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)); @@ -1360,9 +1361,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; @@ -1377,9 +1377,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, @@ -1576,10 +1584,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