Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3802916ybn; Fri, 27 Sep 2019 11:35:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxYCUWTVO68I1Np0y8/nQ/MTJKa6fuXCZf1J+x6k2g2/2FrqPc+gVXe4Fj69VzcPxCvLFA X-Received: by 2002:a17:906:244a:: with SMTP id a10mr9115200ejb.137.1569609328076; Fri, 27 Sep 2019 11:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569609328; cv=none; d=google.com; s=arc-20160816; b=fhc5DkYELobJSAkIF7Qa3/44GC4WW9Xz3DHFXtnEfFzT1GDZUYyconoBAxGVGxmDDg e7uPAbCmePHWNlM2eHyUPUmfX/odngoFWZbG+oQLjV2vhEs7tbLJRwIwTJtYEnmI4Xwy PVcIbCfaSNXoGJbo4FfdiZKRxK1kyesucIZjqScDZcbMosLHCBqyI5II/l15sPZ9wsIT h4U6AA4ejqSrT2YLgZInh4AkiPyqj+oDff+oYeCL2ej3BRDqQqWFm9y8OTHT6zyQlNzD ka5Av4A8tujzFUlYAr8vmUeTKdjM+IHWfftR2LXkwDeCGwoAbHKPcl54/LIdmkGFCUgR 7Bqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=OKhdMxSgs6BN/L1NKmWbLiSeixvj42ucz1234m6E0RQ=; b=Bj7MpJ3n0TTURcowJGXlSSmA+5Vuy+l3JUD+eBWGbdjimf5cn94R0aWfUXfMJ/7xP4 ile4aLSl+3qH5c/ZH8MUtyP/1FXWGuHFe2tJSpCXKEqDQ5hn/aVzPJ5USdUyo6BLr8g1 JpLqSqpxANSzSzhaXvEYLGyBC5ZlhNFXy0HaKfpbb31s4UgxP6MHUNwQ5m+C9L9TprBp GGOJ+/Kk38zQJOVoL+2qDgWe+kclE5OnBx6drLbV6HQPYiUQaswdWcBbxbG6Rguyao8b aGOnggiU651Un4rRHiY4HbKvYO5wUfaT8GXgVABrcUksDToLa+18XKJkhjGk+d1xmbP8 ol0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=C5ElLHig; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si2647941edf.328.2019.09.27.11.35.02; Fri, 27 Sep 2019 11:35:28 -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=@ti.com header.s=ti-com-17Q1 header.b=C5ElLHig; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728243AbfI0Seq (ORCPT + 99 others); Fri, 27 Sep 2019 14:34:46 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:47052 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728066AbfI0Sep (ORCPT ); Fri, 27 Sep 2019 14:34:45 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8RIYi5Q066326; Fri, 27 Sep 2019 13:34:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569609284; bh=OKhdMxSgs6BN/L1NKmWbLiSeixvj42ucz1234m6E0RQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=C5ElLHig2gotPUek+F350S3wJVIrH4xBqlc9ceoGaqvCTsg1LEzeyn52kachhbeQm pmFqplGxDTQWYbVvhE+pRWIa1k+h+SrJ4RltshxGFPGuI8/sFrNrzb2yfMo1WOeO3I T7s3mITtgoMjRQa/FZOdfp/QaiYNuas+JURvahvk= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8RIYibd122641 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Sep 2019 13:34:44 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 27 Sep 2019 13:34:35 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 27 Sep 2019 13:34:35 -0500 Received: from uda0869644b.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8RIYgbp073031; Fri, 27 Sep 2019 13:34:43 -0500 From: Benoit Parrot To: Hans Verkuil CC: , , , Benoit Parrot Subject: [Patch 02/16] media: ti-vpe: vpe: Add missing null pointer checks Date: Fri, 27 Sep 2019 13:36:36 -0500 Message-ID: <20190927183650.31345-3-bparrot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927183650.31345-1-bparrot@ti.com> References: <20190927183650.31345-1-bparrot@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A few NULL pointer checks were missing. Add check with appropriate return code. Signed-off-by: Benoit Parrot --- drivers/media/platform/ti-vpe/vpe.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index 5ba72445584d..56f60dbea15c 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c @@ -1537,6 +1537,8 @@ static int vpe_g_fmt(struct file *file, void *priv, struct v4l2_format *f) return -EINVAL; q_data = get_q_data(ctx, f->type); + if (!q_data) + return -EINVAL; pix->width = q_data->width; pix->height = q_data->height; @@ -2001,6 +2003,8 @@ static int vpe_queue_setup(struct vb2_queue *vq, struct vpe_q_data *q_data; q_data = get_q_data(ctx, vq->type); + if (!q_data) + return -EINVAL; *nplanes = q_data->nplanes; @@ -2025,6 +2029,8 @@ static int vpe_buf_prepare(struct vb2_buffer *vb) vpe_dbg(ctx->dev, "type: %d\n", vb->vb2_queue->type); q_data = get_q_data(ctx, vb->vb2_queue->type); + if (!q_data) + return -EINVAL; num_planes = q_data->nplanes; if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { @@ -2481,7 +2487,12 @@ static int vpe_probe(struct platform_device *pdev) mutex_init(&dev->dev_mutex); dev->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "vpe_top"); + "vpe_top"); + if (!dev->res) { + dev_err(&pdev->dev, "missing 'vpe_top' resources data\n"); + return -ENODEV; + } + /* * HACK: we get resource info from device tree in the form of a list of * VPE sub blocks, the driver currently uses only the base of vpe_top -- 2.17.1