Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3842122rdh; Tue, 28 Nov 2023 05:29:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPA6m/JE8Sc4m/nSL3TNp9LM1LWfIdkPjwkDOlz2BxNKk3tWeOLaTd4BQqTWb04aithtr0 X-Received: by 2002:a05:6e02:152e:b0:35c:b333:a853 with SMTP id i14-20020a056e02152e00b0035cb333a853mr10085219ilu.23.1701178194788; Tue, 28 Nov 2023 05:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701178194; cv=none; d=google.com; s=arc-20160816; b=Z/6ln1v8oxD7aCuT7gG1C4coFEJr1IlL9DpCiRonSzWNDZZWZB5brCYsPiXjB9VZFT sbgxy/DBBOWdoT4Tz2mKlz1Cxfcwm1vLLnT3elTNsc4tsyJOBtly1uDbfH9sxjRt8qHa gyNz7P+ubVg0n8tRD7PmVY90jwp974N7bXJZTVhByBguxqu/xW/PXMAsJL20vrYOKHcK mSo7nSfpkjlBnlz8McUFlw9T6O5ABUeN1+LxPRgIvRcuL2tq8Z3Efq1OpRzpGsCdLXX+ PIONdXMimHOn+Y8XHxPKmMBOtK+le8gdlnajfD1sLt43h33uG8Ney2M8x1ccHVyB7ken YVVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=N3pCF+UJFDbb4Whyzr/Xt55XmsQE3MzmCYd5vLu802s=; fh=ryj0/1qZsDzVM7KezUSDnUx/tDwzQPmZKCL965lbTmw=; b=Xyc9NKBayORM28ujJM9nMymOmI//SQTQpm5ESv8giGYJdfcRNXXeah+hwJ4hymK+nN 9nMSTEfRmWj1ahB0H/+t+m5DE80lOU+Xmm/bpSYCVZ8OKmGup9jBQxa6Slo/YDO05ggu oH0h+wkEIRRS4tTjcglhDGFTajr4NeWZFVRaEMdINrgGKwrJfNlu5XOao/iytyFUF5pH xn3iIzUG+Z638RQVrYL1iFy4oIUzd8MDNmYkJsfD9Bw0o0w/z3XpYxti1r9V5CIVkG01 TP4akKoPr+VzppmuN0k03BdxDIil3kWwEci2TgOMIUXiYgM4AaCscwuu+IyaYQb4HgEn Sgqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jq7O6PHR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k2-20020a634b42000000b005641315d956si12431953pgl.147.2023.11.28.05.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 05:29:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jq7O6PHR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7068F80AC8D9; Tue, 28 Nov 2023 05:29:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345263AbjK1N3j (ORCPT + 99 others); Tue, 28 Nov 2023 08:29:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344875AbjK1N3i (ORCPT ); Tue, 28 Nov 2023 08:29:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785EBA0 for ; Tue, 28 Nov 2023 05:29:44 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C68D8C433C9; Tue, 28 Nov 2023 13:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701178183; bh=eegc62CSFJSGMpwmfbQ9cieR8ro9QUfxI2Hecr1t0d0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jq7O6PHR6YExx9eupodBnBU26Udoi6FMtcX3bU0B51+pFSeHpJij8cLvwfre2NU9r hlU8qmy3P9IKCI32NGfGoni/pILrS/N0Cck3Tw7ijrhJCX1Sf7O7oU2BFFkwWdJZNR iiQeyGhKbsamyvQTl7kyEyLKkq+N2PPHIolJ5kOfAAHS1dm/aR6mTJirWaZ/FWN7tf 0D1yIWE/TUPh7NQQ1aZp2qlVgarhL3nEIZNzaQVa5OpJCI47SJqKml4TEp3yPS9Ti8 JMc/ozLQGq95jIAU9G6MmFGXMRLW2Otb9xTDH8Yas6bpLF9Wg1eT7bbYXmlO/TiwG2 JdNpUHuh7JNOg== Date: Tue, 28 Nov 2023 14:29:40 +0100 From: Maxime Ripard To: Jani Nikula Cc: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , Heiko =?utf-8?Q?St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hans Verkuil , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v4 05/45] drm/connector: Check drm_connector_init pointers arguments Message-ID: References: <20231128-kms-hdmi-connector-state-v4-0-c7602158306e@kernel.org> <20231128-kms-hdmi-connector-state-v4-5-c7602158306e@kernel.org> <87h6l66nth.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ncmpulkgjsh2p7e6" Content-Disposition: inline In-Reply-To: <87h6l66nth.fsf@intel.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 28 Nov 2023 05:29:52 -0800 (PST) --ncmpulkgjsh2p7e6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Jani, On Tue, Nov 28, 2023 at 02:54:02PM +0200, Jani Nikula wrote: > On Tue, 28 Nov 2023, Maxime Ripard wrote: > > All the drm_connector_init variants take at least a pointer to the > > device, connector and hooks implementation. > > > > However, none of them check their value before dereferencing those > > pointers which can lead to a NULL-pointer dereference if the author > > isn't careful. >=20 > Arguably oopsing on the spot is preferrable when this can't be caused by > user input. It's always a mistake that should be caught early during > development. >=20 > Not everyone checks the return value of drm_connector_init and friends, > so those cases will lead to more mysterious bugs later. And probably > oopses as well. So maybe we can do both then, with something like if (WARN_ON(!dev)) return -EINVAL if (drm_WARN_ON(dev, !connector || !funcs)) return -EINVAL; I'd still like to check for this, so we can have proper testing, and we already check for those pointers in some places (like funcs in drm_connector_init), so if we don't cover everything we're inconsistent. Maxime --ncmpulkgjsh2p7e6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZWXrRAAKCRDj7w1vZxhR xTyXAP0W+h2/0xLXXBJVtoNPSJ+MdMt1B3qXNmsRScATV36j3QD+JmPDNBt3syJA 33NzAAvtBetz/KSX6B52Yckf1U8lwwU= =KHiZ -----END PGP SIGNATURE----- --ncmpulkgjsh2p7e6--