Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3258065yba; Mon, 8 Apr 2019 14:46:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyy+ra6gviuYeD4ZDMQ0yMaKSoBneODJugVpJ7Upd0HE1a5+O4mlpBZuORIeF4tmQOFCtvx X-Received: by 2002:a17:902:d70c:: with SMTP id w12mr33170005ply.198.1554759959928; Mon, 08 Apr 2019 14:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554759959; cv=none; d=google.com; s=arc-20160816; b=aubaJVrGqpaa+HM6q36ijguUit3oofL+qT8c37i+/lR1werxyGtEpu/C5Ovu1UFVjs 0hDdA2XpwKJzvomY2Z1qtDD7NPoDTNh4adhs4DXGQxVwQQJKjmUf6BJP+TVRMoMBeNs0 eD4d84GNepYsYnGO6ghShbEvazm2vRzZa6MUdHIv8mbvCkreyiOg8VJyaAjGjwcqOYaS E5dMGE/3aj/hMQPoAL7/GpikN6aTMgar3PL/OjpgBMsMwS7qZNHMLxh8p6h1r1rfYubP fiRyMO5EWbxwl33VL06e/15oYOb+UKK/pYI+1SLnr9mOmN/FCdNurAPriHCeCcI5b1DH m/0w== 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=rbgUHGjL1xlbhm4c7TA1e007Ia4N5yQjhJSCjSQrlG4=; b=hhaQQ1C4Y0zhAD9NFGbDV5GMB5MZpfFxa7+oI4DwNyHTxmciCYqTuFjIir5fRaxgpf S6TlCe6VFGV/TTVXj3tLZRBjE7jvee3qPhqxsZ+/Km32G6yMKPRuE+jTquPs4nSjxGLD q5ywsRqqbijSYwt54zwZQ7e89WnE2liU4eDlN1zAwYVFBAOqHB3sdEmthgFhITPIDqZE AdXeFZkAzJAvpI9RZIbK4e6HEE2dqsgXfU1w0Yo+PA1HxyWw3PgwaDUSjssin5seq9EM wblrTW9DiPsJraJth3mA7Kzpm3Ie+GekTnDFLLfjkboXqaIXw9AIa4NlVN5GB0pTnonm NKbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gz2yzpBF; 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 a1si27315978pff.258.2019.04.08.14.45.44; Mon, 08 Apr 2019 14:45:59 -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=Gz2yzpBF; 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 S1726924AbfDHVnT (ORCPT + 99 others); Mon, 8 Apr 2019 17:43:19 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41667 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfDHVnO (ORCPT ); Mon, 8 Apr 2019 17:43:14 -0400 Received: by mail-lj1-f194.google.com with SMTP id k8so12614235lja.8; Mon, 08 Apr 2019 14:43:13 -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=rbgUHGjL1xlbhm4c7TA1e007Ia4N5yQjhJSCjSQrlG4=; b=Gz2yzpBFmZKAVC3+G4MSMz9MbVA6uZZz81GdKDIQjv2OLQa5OJgapvd/gWAoBN/W3N d5c/eacu7gHMpO8hDJ/6rSaRjLjvxqqA0XY2DrqFiiBr367oX3sS7y5y0GaSK9xUbnGD K0Y/q6X8Bnu67LGPv/vrGWRR8lTdKX/sCtqdWWDGVOSDDkexs3VlWDwVDH8Y/xPoZW8/ /D6jFuIYw5geVquOTVdQUWouhxHvDCI8X2jL8UXcaPo61hIWAi74fCrdo+G8aRZxPzKv lZsl3F+jSolFiWISXm+qBAwtOQ6fXmcV1Q0gOcIFTiW6lizXlKi5JADSSsGTe5uZnCZn 2l9A== 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=rbgUHGjL1xlbhm4c7TA1e007Ia4N5yQjhJSCjSQrlG4=; b=Pzw9vsDbZJrfmQq38ya/ZSgYj1uy8phXcZsj3jBZRM6zcTpBqEa9iUod0orYhcyCci HVixrrQuBcqowsob3CrpBkUe+zHdRw2G0mPdqFsuMyi+5ah1vc3MyoghJ/f+c83GYota ZVBMKeEJWJV+EIPJqXhVn1WpIiyPFuAtS64zftOy4hlB8xAqCj4RabhWrfockv2bSrVT +ZzX3GOQChRm3RpPtHSLq5jxCHzWFccGITdhHtrROqnm8DXOwtirr/DfLHU80oxupS9e QXEXfa3O4of9SmG0gyC6qlnehsiH53m9nmJAwkw2Cd1h3U2040O6jAqoEGPn7D+Fd40/ Cw4A== X-Gm-Message-State: APjAAAVpgao5xRKbVjrlZdmja+7h2IcLWG7V+XKCEwUPur/jdfC7V5Ur 1AZpo/Tlyo97Ah9p3zTUVGo= X-Received: by 2002:a2e:3803:: with SMTP id f3mr18200964lja.165.1554759792252; Mon, 08 Apr 2019 14:43:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:11 -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 05/14] media: ov6650: Fix unverified arguments accepted by .enum_mbus_code() Date: Mon, 8 Apr 2019 23:42:33 +0200 Message-Id: <20190408214242.9603-6-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 ebcff5fce6b1 ("[media] v4l2: replace enum_mbus_fmt by enum_mbus_code") converted a former ov6650_enum_fmt() video operation callback to an ov6650_enum_mbus_fmt() pad operation callback. However, the function dees not verify correctness of code->which flag and pad config pointer arguments. Fix it. Even if the function has no need to dereference the pad config pointer argument, return -EINVAL if it is NULL on V4L2_SUBDEV_FORMAT_TRY. Fixes: ebcff5fce6b1 ("[media] v4l2: replace enum_mbus_fmt by enum_mbus_code") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 5c1738c5a847..d72fcf56930a 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -737,7 +737,21 @@ static int ov6650_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { - if (code->pad || code->index >= ARRAY_SIZE(ov6650_codes)) + if (code->pad) + return -EINVAL; + + switch (code->which) { + case V4L2_SUBDEV_FORMAT_ACTIVE: + break; + case V4L2_SUBDEV_FORMAT_TRY: + if (cfg) + break; + /* fall through */ + default: + return -EINVAL; + } + + if (code->index >= ARRAY_SIZE(ov6650_codes)) return -EINVAL; code->code = ov6650_codes[code->index]; -- 2.21.0