From patchwork Sun Feb 11 15:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniil Dulov X-Patchwork-Id: 199467 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1967856dyd; Sun, 11 Feb 2024 07:08:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTxbKnfMj146YiUEX1A1kT8HUErAhmnyNY7/VCnGPD4g2UBN6Ku30Vq+UxjyjpZw1nxo68 X-Received: by 2002:a62:d147:0:b0:6de:1d0b:ae29 with SMTP id t7-20020a62d147000000b006de1d0bae29mr4156710pfl.0.1707664109469; Sun, 11 Feb 2024 07:08:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707664109; cv=pass; d=google.com; s=arc-20160816; b=VpA4IBO5VfoQU5xSucEp5DL8mckWpPU3eL879UIj68aReRovr5wStXqcPxel8OFlXt 3gmcIaNL07udfrFWXpBXDOgiBHnqNu5iBKZUjIBMche/fxCarxEU7wScnI27/scTxuBZ P7LA5pqiiFdRp8+xXnO1/vso7G59rQXQCGF6DERJ6G+EzJyZWdOBGcCcCBWMHIJhTnGa nIi4scImeqvEVCgY3LjGD3saIzyFVmUa3itaVpGVc/sj3m0R6jmO8cjw23W4oLQAev9F 2r+nyZSORhWmTh117uMUrSgF/DwJ1J62XL0rT19n8L5RXqI1HGv2LNXoCrVxZIStY9KP JNMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=IlY1xXkKAoGp3Vs09q+voA6r6dQmLshqPP6a1Rz6ok0=; fh=13Puhndf7axUUz4PznkgrfAR5ur+MAhMdDKjZG8czJM=; b=k+a+v+lgrZTRwUogUYd7YYHawv148bixqIKu77/jhTGWOuZTo5stVrSGZx2xw7vfvH W0zrUI+dlkJfG0l5A2IRjZ7AL2fCrUEuSsWqo/fxuGkZA08dNeBDhzr/HJgJzKJUIfbW yoAWD7gAbdbc8b1JyGtg2LbBIknc4UVdbJUX/Zp70qVjvxMrMLedCPpjIUgrf2Iv5ZR0 FCqZZCifht/7GfZiIerZ7KTJzpeWBtl9Nz1S3zYMlQPDgiYg0gKgb+GDC8Qn60HU0TBw n1AOZnYuo0/qz0GtSXm9IQbe4Fae0S7SxkSZZrKPM29jUDbONfLkMIeXocVussyjgSPS VsSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aladdin.ru dmarc=pass fromdomain=aladdin.ru); spf=pass (google.com: domain of linux-kernel+bounces-60815-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60815-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aladdin.ru X-Forwarded-Encrypted: i=2; AJvYcCW5CF5lbQ7NZ/eavPZ1PqCG5tv0N6swk3Zz5Q6vPftinbtbgLM7nem3UDvtShrR216AQV89PXRSqEU0XQ/drb/rWzMIxw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e30-20020a056a0000de00b006dfeb8b8043si3568498pfj.74.2024.02.11.07.08.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 07:08:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60815-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aladdin.ru dmarc=pass fromdomain=aladdin.ru); spf=pass (google.com: domain of linux-kernel+bounces-60815-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60815-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aladdin.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 34042282440 for ; Sun, 11 Feb 2024 15:08:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E86C5C5F0; Sun, 11 Feb 2024 15:08:05 +0000 (UTC) Received: from mail-out.aladdin-rd.ru (mail-out.aladdin-rd.ru [91.199.251.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7641C5B5D0; Sun, 11 Feb 2024 15:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.199.251.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707664083; cv=none; b=maRjLFilESvV7KPn2ZYtvG3XwxERojgzP3EiEzRxDEsKNAn5nYXRTZr6nFSc+bldaOqJHyCTLP2CF3gxT6CqPoGaFHhxDw2/eo449mIZDv+X5E/11FFIMrebQfewRHiBrNrbbIoSl+8+icYsH+/lk8XYponEqJixd2Je4yt8EUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707664083; c=relaxed/simple; bh=sueJpulddtDvnQgZUkdO21U1DNcg8cZRkMNzuFg+1AI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=sWnCI2Hlz6JYLTjJan/NaFF25ik1SPm6nEqjKlRYUaHzruxowFQ/AknH5XFwiRodE+0EkmVGnkt1Irds5Ry6GeBPkUaCQT7+JLOQxc6KyOIpLPh3xVSA3AmjEHCvXuCiHk6CDrx7G6yYSBtLm314IgpcGKTV4sLPAYob1Jl+gZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=aladdin.ru; spf=pass smtp.mailfrom=aladdin.ru; arc=none smtp.client-ip=91.199.251.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=aladdin.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aladdin.ru From: Daniil Dulov To: Mauro Carvalho Chehab CC: Daniil Dulov , Hans Verkuil , Takahiro Adachi , Takeru Komoriya , , , Subject: [PATCH 17/17] media: upd64031a: Check return value of i2c_master_recv() Date: Sun, 11 Feb 2024 07:07:48 -0800 Message-ID: <20240211150749.3832-1-d.dulov@aladdin.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EXCH-2016-04.aladdin.ru (192.168.1.104) To EXCH-2016-01.aladdin.ru (192.168.1.101) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790615601277374795 X-GMAIL-MSGID: 1790615601277374795 i2c_master_recv() may return an error, so add a check and return 0xff in case it is passed. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: add953cecba8 ("V4L/DVB (3665): Add new NEC uPD64031A and uPD64083 i2c drivers") Signed-off-by: Daniil Dulov --- drivers/media/i2c/upd64031a.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c index ef35c6574785..f51f86f30c73 100644 --- a/drivers/media/i2c/upd64031a.c +++ b/drivers/media/i2c/upd64031a.c @@ -73,11 +73,12 @@ static u8 upd64031a_read(struct v4l2_subdev *sd, u8 reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); u8 buf[2]; + int rc; if (reg >= sizeof(buf)) return 0xff; - i2c_master_recv(client, buf, 2); - return buf[reg]; + rc = i2c_master_recv(client, buf, 2); + return rc < 0 ? 0xff : buf[reg]; } /* ------------------------------------------------------------------------ */