Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3258375yba; Mon, 8 Apr 2019 14:46:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyerGkAyoIYippxlxnCoYhqJwMlOBXwJHc98gXdvlkonsYt13Wb6msqMRSS4GVUhAMT0j4U X-Received: by 2002:a63:2983:: with SMTP id p125mr31246713pgp.262.1554759989624; Mon, 08 Apr 2019 14:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554759989; cv=none; d=google.com; s=arc-20160816; b=Ygckt1eKaGUwoFy2e9ZTCqq7NAQoBNEXwq4gZuEgPgsRxrTkuOcsjGDc2Zt5lC8ke/ j/nY9IamE+NHJ7uwsdhZSV48mkMzqIeldq99Fcuhb/Kcw+PFmvA9pXilKTfnm+p0k4oI sW22rotHWEQb5OhFAslRI7s83FcexUlz1NUoX9l7SlXs9Py7FTEwtzYJQDMMcyfEsGWB E3syVCX5qDX88lNWdloAq6qmGarEmlBaPlvVn/LVJjKKNrE2edGBeTGCUWa7mQYiNL12 dnW3bNmrnqx2QveBz2LN/oA/v+6dvI+1ZBKpdAN8q3liNARRULcOv3Z0ZvVa3jmjn5W5 MXsQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wVGmZYRQa/9aCw2opSqt9la4dXQ+gNuOGKIGTuXbWis=; b=X9ttzcHwRoEFAZcxvYwkMHWuXBy3YKAXAvyGOUzNgiatroRPqkEC0BLbosKDPMAzQQ X67gFB3GFIStD8ri86mcxcY8WsxGsK+yzj7e4zK4GsFpDX20lGyCuo4KacKicW8J3MDl aPCsl4j34t3ENejUiyegpDF2pKWV76ltA4MH/je8AyUsksyE5z4b4VIn3vL/Vg//DMiR KRJeNvpRqCfiEW7RtR1RWc8nlmWh+mYoYp4HlMl7TUY5U4dM6NeKoX/ZbheruExth0op GuF+kiev6V4vvAckVMnNmP5faQmN1U5dtB+L0fSh0OY/y0DFklJQCd93jZmntqcJZdyv reBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FL1aVqaz; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23si27369181pfn.99.2019.04.08.14.46.14; Mon, 08 Apr 2019 14:46:29 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=FL1aVqaz; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728782AbfDHVoe (ORCPT + 99 others); Mon, 8 Apr 2019 17:44:34 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37436 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbfDHVnM (ORCPT ); Mon, 8 Apr 2019 17:43:12 -0400 Received: by mail-lj1-f194.google.com with SMTP id v13so12621426ljk.4; Mon, 08 Apr 2019 14:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wVGmZYRQa/9aCw2opSqt9la4dXQ+gNuOGKIGTuXbWis=; b=FL1aVqazYKyeiRdnsIA7ddxCVe0Za9WN2WqRdAKtqzjisAhJH8ey3NCk58rCjxY6mv fF7EqAcyglUEgTqJURsbvfgy5oY0gn5c9XuNjxr/xRZdXCERpKpJq/oTbQpD98d3A97F rcf9w9K931fdlpf8y5dfwPaIl6LxeuOKyxpW9xOk8w3jeTXOWScmnEiiUBsN1162dYbM xlLtkOC1eRAUP4/qbCai8bRkhZmjJr5sC0YzY8+9CCdn9XKr3LBeWOSMpeb2UTspgbx6 fLemcikKvnyD0Zc4D//MzbzWnZFjNu2vR0+yFQkkruz4JF+PbhtmDD3a++OEhxEaenLL vkMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wVGmZYRQa/9aCw2opSqt9la4dXQ+gNuOGKIGTuXbWis=; b=S8AA4Y92dCkLga5Dh8e++UGoLm67LOHiT805KLUyoVPWUSQvUf9zRegNFpxCyeR436 PNYCmnmIShW8Ywr5e51yZFQjDoynbLXM0KrrwxI7HgsNgjBKut3Mftbz1TUCcpW0QfXn SAOTXUA7VFKwDJHy3gBMUn12N9bDQLc0+KfxSOvlNK/EeZ7A+rOokLbm1Sz1XMm0q/lM +tOlrI1hFPaNwHHjxJ8PoHKB0sBbXM52VfEdRSSJBzq/6+P0uWMDe5MdsmmZx3OCEQ1R YknsaVNnpCxrOVdpCjqKWdaPMRQL1SsZTebL5voIShMGRv1NBnpqQE393TRVCZv4rGMu tVpw== X-Gm-Message-State: APjAAAVX6RPWd9J0ZUdIrdSY2m8iTi7oqw8Tk27LcVYlc6l1hUwmPyvI V02rxeK4W52X9uWiVsNMhLo= X-Received: by 2002:a2e:9e4d:: with SMTP id g13mr14908111ljk.12.1554759789708; Mon, 08 Apr 2019 14:43:09 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:09 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 03/14] media: ov6650: Fix unverified arguments used in .set_fmt() Date: Mon, 8 Apr 2019 23:42:31 +0200 Message-Id: <20190408214242.9603-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 717fd5b4907ad ("[media] v4l2: replace try_mbus_fmt by set_fmt") converted a former ov6650_try_fmt() video operation callback to an ov6650_set_fmt() pad operation callback. However, the function does not verify correctness of user provided format->which flag and pad config pointer arguments. Fix it. Fixes: 717fd5b4907ad ("[media] v4l2: replace try_mbus_fmt by set_fmt") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 007f0ca24913..3062c9a6c57b 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -679,6 +679,17 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd, if (format->pad) return -EINVAL; + switch (format->which) { + case V4L2_SUBDEV_FORMAT_ACTIVE: + break; + case V4L2_SUBDEV_FORMAT_TRY: + if (cfg) + break; + /* fall through */ + default: + return -EINVAL; + } + if (is_unscaled_ok(mf->width, mf->height, &priv->rect)) v4l_bound_align_image(&mf->width, 2, W_CIF, 1, &mf->height, 2, H_CIF, 1, 0); -- 2.21.0