Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4073836rwb; Mon, 21 Nov 2022 03:26:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf7asomJ9zMATZQAUt1mRvk98kr+1EYqZieeMP6Bx/JlDGg+9AcQHtaTaE4npYTKAIXjwV+1 X-Received: by 2002:a05:6a00:1a88:b0:562:bcf8:7b35 with SMTP id e8-20020a056a001a8800b00562bcf87b35mr1545368pfv.52.1669029965920; Mon, 21 Nov 2022 03:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669029965; cv=none; d=google.com; s=arc-20160816; b=Reh9nCn8NTrBcAevNpzPvyfvz0dg3pMUfZk9ZKVPKlRpeaQL+Pgrrj7daKQOQOKBmz vsd4Hsj9ACMVpP4J78t/moaXMY1MEEFjlkdOfL7Fdq/Cql6jqI+ZI2Q5b/L7LlyPnMiQ 5BVrYHsur/zzmqylsk3Wym8n9mKY2h3oskjBd+LFs2mX73InXgBtCVliAeCOxh2V3pOf lU54h1PfG3tGGL8piqT5TbTZkFmKhmEf2ffu/GQFFXMb0HNns95y7BBVMIAzuebxbzyr qNW7vMzZBpnvf9xH0iGzqh+A+74xos5tPmnZTy2kvbaXp7N6SPiid+aprh48qbfOuj2y e4Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YKmL238oBqxiRNanxS8WxENXsxx4KWSkzL71xeQ1GGU=; b=wvySM1rpsHibHbEdrprZx90/mUiS+ywYza15JIXXhbQwje0UcBFqmxoFqGiv0E5e4x KMvqJpJNYVKTrNpJdWs9Psq/nqJe6sY312CfZ04FEVEoF/OdcUJqCLCFhd/O0Pi2fJRC iQkpvmJzW8LkVdR+Fw8n1GkZmpBNU/r40ozYr7zNwOpnqLDp8jZFMB7VUnXBD0UDkwQv xdCAURZwFp41y0LNZwNNK39hYniYOAg+px3U9H0XoqonmGQxKans2Z/AIfZegD03Z1q7 wLo74g1vzgissCxCCq1+zwNaaUFugtW7ylJ+E05STrSdvK9n+BlcphGkYzRouW9zz+Gt ysHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=cmTtkZsR; 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=raspberrypi.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a056a00140500b005644806915csi11429922pfu.42.2022.11.21.03.25.53; Mon, 21 Nov 2022 03:26:05 -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=@raspberrypi.com header.s=google header.b=cmTtkZsR; 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=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbiKULTf (ORCPT + 92 others); Mon, 21 Nov 2022 06:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbiKULTE (ORCPT ); Mon, 21 Nov 2022 06:19:04 -0500 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E117B4F07 for ; Mon, 21 Nov 2022 03:14:21 -0800 (PST) Received: by mail-il1-x135.google.com with SMTP id f6so1449306ilu.13 for ; Mon, 21 Nov 2022 03:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YKmL238oBqxiRNanxS8WxENXsxx4KWSkzL71xeQ1GGU=; b=cmTtkZsRLYZ2I7OrrX8A0P6ENVcoRjlUIfcoXkb+53K2jA1qr5lGYrpVGseSq278q+ GLJCGg6rHlo8FEqW8LGQIYXFXJ5a5dwgunZ0fsd/adJPLzAbKdLRdKwSMgVFFqHd8hQG QO+fLy+vT8HOklP/uCk8dmMDdSwlr2Pl3c1yHtisY48EgVuuNTCiR3Cv3kjqmx3yqnQA uLHHCB1I18mgGAPJfPMwZAiURQL8TotvBLKGsFUCKCUpbVnE75cRojgHxAfmG9cLwOEb 3U9B0C87KNHCKtfe5vPO4y0MRAFZ18zJtZZKROYda8xVEfwb/7M2z0I4epl0nYHUU/Hw xZrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YKmL238oBqxiRNanxS8WxENXsxx4KWSkzL71xeQ1GGU=; b=XScqbUAHIVn7YPk7AQVtTBEO6fiBWZYc+9Hqf+jT5+58w9AkiiB276hfNjra5z4Sa9 uQPe33knTStQajnoZo20/eVpGbSN88Xc740DIUYsbdPvlzRqO5aj45pLMbAwBmrC3yUX 2Br5fnDPhNPm+bCz5R8yY0k53j+RsXfq3bQAK7bYcKdZrfnrRGjqD8+ihExsdJ/EopGz IlaUYQZkz0GbAVs4w5ki0nX2IBp/2vlQ/LBOa8H5775tknUnLZ3p+QqKeSbRr779iSJB fH2uR7DDseu33jv8ibXfH1eUcs21BvEZJe4gp5f5n6ErEcMjzg5sjeN5wFQLQChXwxWb W++Q== X-Gm-Message-State: ANoB5plqPVkf37tbS4qZ//PUzBuD5Dh7KQgEH85QSZVagtRwm2I4jJRh lszFI6sAkf9l3Nw8DlGp/gSbhg/j5GVLKOKyAaBnqA== X-Received: by 2002:a05:6e02:523:b0:2f6:9105:7a15 with SMTP id h3-20020a056e02052300b002f691057a15mr2247770ils.292.1669029261089; Mon, 21 Nov 2022 03:14:21 -0800 (PST) MIME-Version: 1.0 References: <20221120142737.17519-1-LinoSanfilippo@gmx.de> In-Reply-To: <20221120142737.17519-1-LinoSanfilippo@gmx.de> From: Dave Stevenson Date: Mon, 21 Nov 2022 11:14:04 +0000 Message-ID: Subject: Re: [PATCH] drm/vc4: Fix NULL pointer access in vc4_platform_drm_probe() To: Lino Sanfilippo Cc: airlied@gmail.com, daniel@ffwll.ch, eric@anholt.net, emma@anholt.net, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, stable@vger.kernel.org, l.sanfilippo@kunbus.com, p.rosenberger@kunbus.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,T_SPF_TEMPERROR 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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lino On Sun, 20 Nov 2022 at 15:26, Lino Sanfilippo wrote: > > From: Lino Sanfilippo > > 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 Acked-by: Dave Stevenson > --- > 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 >