Message ID | 20221120142737.17519-1-LinoSanfilippo@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1146390wrr; Sun, 20 Nov 2022 06:54:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/mkZAezkI81TFHw6CZk2w9aHD6is67pCSM3Tydv9/4sHS5ydTe5sfJtxq5DizqkfKv256 X-Received: by 2002:a17:906:b80d:b0:78d:314e:b0fa with SMTP id dv13-20020a170906b80d00b0078d314eb0famr1861188ejb.370.1668956099170; Sun, 20 Nov 2022 06:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668956099; cv=none; d=google.com; s=arc-20160816; b=oMXFNJeKLB5pCENyav2f484IJ17adiTAcg4iGtMFamWlVAovtW3hHNj7Rn4wrNJ3t3 jRKLlAZR5+DEW8JfRM/GJKkx8Z2c7tw8EXSRni5ybHjVDdnU9oyvteceNXjNSf8dDnMO fdF/HxMYTMngPll+rtHBYT1sV2PLI2D9JoI+hBckSo59HuL3iKW2RHDzYXd33st68YO9 ERiIgk77yDq/BUqqzes4L3oGnx1YeBrj9bdYqzFIU9M+i0kIjIb+ebNbHoI7re1tFmmW /a87wb8VWyMCNZVvsxa2F8/9EJdc1Umg9KEb3AqFCcVKE1KLDw5+dlLQV018UaNqk1eM T0cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=FFLjOZn0sVHKOreaEmKwpRdWPja50G8UcNn6gnxIzrY=; b=Ep1SRtMbW28FueAaOjPrWpLwrZa3i30r/s0cJlseawpQA6muW80MmQDize106KpZuM Yw2p+CAJSzpy1nYNz9rNMugm1s5rtb6TpoMruxHq6eW+sJJcMFMa3AgkzHw44p4Gy5GR nsVruxArvBbl8ukO/WC3cW6dp7+mpeL4tcsglhUgi82leserMD/0h1rLyfO/L19JrWXq 7TQqN/pSOkiV5kCmZT5zYDHFLZ2DFgcUM79KZYHSIUa9nked3kxeWK5N26BqcHWacSC/ wb/bavmgm9z8oSj55HAA28uRRUi6uqcDesv4sOB+o41nzc8zD2wGS5saJ+Gahu/rXBfv fy7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=ncSXXE3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xa3-20020a170906fd8300b0078db79317bbsi7368982ejb.689.2022.11.20.06.54.12; Sun, 20 Nov 2022 06:54:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=ncSXXE3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiKTO20 (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Sun, 20 Nov 2022 09:28:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbiKTO2Y (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 20 Nov 2022 09:28:24 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3A413DE4; Sun, 20 Nov 2022 06:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668954490; bh=FFLjOZn0sVHKOreaEmKwpRdWPja50G8UcNn6gnxIzrY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=ncSXXE3CeosOJ1S0V0vpONVMqGIFacon2JAF5mvmrhqfFuDfJkYgEN2H2rDg0dH2B wS2X4g2u4e/Fzo8CJ3EDfNi6csfNJJWip/UmTKs9FpxYT+CazJiWjPMIKpq3stQKAG oYrgAVoDXeVeCx1r2Spgqu7KGOHlvhNfj5SC0cKtXp/ErF2PAcPPYIwfB8jHV9WSUA 6xG3M9L7xWd3d3VF53VznP/K+qBTm67WK7grh6vLOQgNhK67e8pFp4oywyvFhGcQ0z OrCONTLmWjSYODPGvvQ41bOrc++B3tUp/ygZxkGUjv3YGeEa4uzDOBWRfJrfyfN20E 5TWTmMC48izbQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MGQjH-1oigGV2ei5-00Gma9; Sun, 20 Nov 2022 15:28:10 +0100 From: Lino Sanfilippo <LinoSanfilippo@gmx.de> To: airlied@gmail.com, daniel@ffwll.ch, eric@anholt.net Cc: emma@anholt.net, mripard@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, stable@vger.kernel.org Subject: [PATCH] drm/vc4: Fix NULL pointer access in vc4_platform_drm_probe() Date: Sun, 20 Nov 2022 15:27:37 +0100 Message-Id: <20221120142737.17519-1-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:qQu1bYLAxugZ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aOi4COBLMf3O3alWzb8m3UJNo3svmgh1eJqUcpym2HjdMWAg03fK4uj9yBbWaZP/eG FEFFrcvqqlGFUvzt4HI1m/43nIrfQmhCqmrn8oALy+OpzJIUH68XnYDXHClTO81RpHDhUN2cP k+YJxQ== X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MIME_BASE64_TEXT, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750027310903553630?= X-GMAIL-MSGID: =?utf-8?q?1750027310903553630?= |
Series |
drm/vc4: Fix NULL pointer access in vc4_platform_drm_probe()
|
|
Commit Message
Lino Sanfilippo
Nov. 20, 2022, 2:27 p.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com> In vc4_platform_drm_probe() function vc4_match_add_drivers() is called to find component matches for the component drivers. If no such match is found the passed variable "match" is still NULL after the function returns. Do not pass "match" to component_master_add_with_match() in this case since this results in a NULL pointer access as soon as match->num is used to allocate a component_match array. Instead return with -ENODEV from the drivers probe function. Fixes: c8b75bca92cb ("drm/vc4: Add KMS support for Raspberry Pi.") Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> --- drivers/gpu/drm/vc4/vc4_drv.c | 3 +++ 1 file changed, 3 insertions(+) base-commit: 30a0b95b1335e12efef89dd78518ed3e4a71a763
Comments
Hi Lino On Sun, 20 Nov 2022 at 15:26, Lino Sanfilippo <LinoSanfilippo@gmx.de> wrote: > > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > In vc4_platform_drm_probe() function vc4_match_add_drivers() is called to > find component matches for the component drivers. If no such match is found > the passed variable "match" is still NULL after the function returns. This would imply a very strange device tree that has bothered to add the drm device but none of the devices that are required to run the DRM pipeline, but avoiding a NULL deref is certainly preferable. > Do not pass "match" to component_master_add_with_match() in this case since > this results in a NULL pointer access as soon as match->num is used to > allocate a component_match array. Instead return with -ENODEV from the > drivers probe function. > > Fixes: c8b75bca92cb ("drm/vc4: Add KMS support for Raspberry Pi.") > Cc: stable@vger.kernel.org > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com> > --- > drivers/gpu/drm/vc4/vc4_drv.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c > index 2027063fdc30..2e53d7f8ad44 100644 > --- a/drivers/gpu/drm/vc4/vc4_drv.c > +++ b/drivers/gpu/drm/vc4/vc4_drv.c > @@ -437,6 +437,9 @@ static int vc4_platform_drm_probe(struct platform_device *pdev) > vc4_match_add_drivers(dev, &match, > component_drivers, ARRAY_SIZE(component_drivers)); > > + if (!match) > + return -ENODEV; > + > return component_master_add_with_match(dev, &vc4_drm_ops, match); > } > > > base-commit: 30a0b95b1335e12efef89dd78518ed3e4a71a763 > -- > 2.36.1 >
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 2027063fdc30..2e53d7f8ad44 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -437,6 +437,9 @@ static int vc4_platform_drm_probe(struct platform_device *pdev) vc4_match_add_drivers(dev, &match, component_drivers, ARRAY_SIZE(component_drivers)); + if (!match) + return -ENODEV; + return component_master_add_with_match(dev, &vc4_drm_ops, match); }