Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1165016rwl; Fri, 24 Mar 2023 07:07:49 -0700 (PDT) X-Google-Smtp-Source: AKy350azCAeOhTTHbLjm71Hl3/Jbmxis0jHeQBRgVhSzR/+olmkESl8gsXTQriqqlFExplwkEwqw X-Received: by 2002:a05:6402:151:b0:4fc:5d56:f91d with SMTP id s17-20020a056402015100b004fc5d56f91dmr2745118edu.18.1679666869045; Fri, 24 Mar 2023 07:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679666869; cv=none; d=google.com; s=arc-20160816; b=vFPxQcFDL6q5Z4I96VcYB7VCKu2zJoHSd5F2yV3hE7Z4+qfhg20sGPh1SKKKpMnr4X tDzwlh/t8Oex7nVh3q0Om6Bd5J5Z1NKxz0LXPfGxXGCM7LQ2Y8m3azWnHJeFrrvbG14m rMevBFSLVQ3SsW0xxL52OP5dnhsgwO4FT3BvVqwYeGXnJUs3pXX9W1qM/NXSSEYMshiv P2EjwTibg9OBF39z3EXN4dXeoTVbKw5YBAC9ZjqEiJ75TdtxKtw/dfUNtDoEIwrUF0Kk gZ/YsfOJQlfA1LvxEqhzjECPmwOlNxHb4c+pRDfJdKOuqBGLZKAiusfElx/mVEJBWSoJ x5LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=EFN3OnvJIC8bOLXnTD3xzdkz9KcF6PgksCHKBXWRCd4=; b=jGE/x4qcCwD0F00xbINr9EWbKA2tK1b3EI7qMzHdKhrpu6u6pay6l0tJRJQU0PSmiR AxsD/eVKJt/ENizkMC8Ag7+CDOfoMsAYEkFjcpRHEFlYZrUsB8PQhnfKgTINkwXA0JoT S67ltTS53hx6WSvyZMU25QPJbQGH6BwF9q/jgJJb7/vG7/X7koQKKLQMROmRDb6O/zTK c4D6fgf8LoelZ/A4UXmnuh7QfNZ52huGFgH5yT28r9TSXefXVBXW5gw8ITzhl8pK8Y+Y DJHXRozq3qP6AOdYwY5VrGCGqBov9fOqB+W5oEhqOt6IDpYmJx0OLCgxnyJTZb0YXd1T SYLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oXYPBUg1; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m19-20020aa7d353000000b00502038c2d09si5638456edr.596.2023.03.24.07.07.23; Fri, 24 Mar 2023 07:07:49 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=oXYPBUg1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231976AbjCXOGl (ORCPT + 99 others); Fri, 24 Mar 2023 10:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjCXOGO (ORCPT ); Fri, 24 Mar 2023 10:06:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B8E1735 for ; Fri, 24 Mar 2023 07:05:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DCDF362B05 for ; Fri, 24 Mar 2023 14:05:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 492E0C433A4 for ; Fri, 24 Mar 2023 14:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679666734; bh=y4Farhu4V41tPk7JQCGgZn32PPH4qculJxU45vIj0EA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oXYPBUg1nrZIdTIcXAT6GL490fkUmTs72+6cEq3KJMtP+pppE2G7XwO1hIJTwRRwF 1V3zAWBFdXCM8WXwu3wGGcOlUckEV+a43aIHc846S9tqo2szGwPpcNzel2NE+qZ70k xTRXNSjNQYu4S9P+VQGcPF+42ZC94Bc/IJbz2zh+/Ih9lUqM4D+QYS4kgT3QCy4g54 OmdeVJQUEGopghqcqlzxN0tC9U0D/zSCRUx+mS5rJLG3rGd0cDTefE9T/iufnWzKhP V1ka4oBgW4Tu4zT1jyrYO+VFck+ez/ncN5wBiSdwPqpB7FCDrmXU6pZdOr7ZHorMk6 fOZUc8f/MspNg== Received: by mail-pj1-f44.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso5129790pjb.3 for ; Fri, 24 Mar 2023 07:05:34 -0700 (PDT) X-Gm-Message-State: AAQBX9edozrXOkV1ba+Urpjk8MgOzA/LZJMSsKs59mN2PB9cl2M2Apwy 5vHjfF/oT/CN5q/hWC31Ak8dd/bd/yXuiHMFjzH+Ug== X-Received: by 2002:a17:903:7c8:b0:19f:39f8:88c4 with SMTP id ko8-20020a17090307c800b0019f39f888c4mr3613623plb.2.1679666733789; Fri, 24 Mar 2023 07:05:33 -0700 (PDT) MIME-Version: 1.0 References: <20230324035909.1727356-1-treapking@chromium.org> In-Reply-To: <20230324035909.1727356-1-treapking@chromium.org> From: Robert Foss Date: Fri, 24 Mar 2023 15:05:22 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/bridge: ps8640: Return NULL immediately when EDID read fail To: Pin-yen Lin Cc: Douglas Anderson , Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On Fri, Mar 24, 2023 at 4:59=E2=80=AFAM Pin-yen Lin wrote: > > drm_edid_read returns NULL on error, so feeding it directly into > drm_edid_duplicate may lead to NULL pointer dereference. Add a check to > guard this. > > Fixes: 6a17b4d1b52f ("drm/bridge: ps8640: Add a cache for EDID") > Signed-off-by: Pin-yen Lin > --- > > drivers/gpu/drm/bridge/parade-ps8640.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bri= dge/parade-ps8640.c > index cddbfe91f75e..b823e55650b1 100644 > --- a/drivers/gpu/drm/bridge/parade-ps8640.c > +++ b/drivers/gpu/drm/bridge/parade-ps8640.c > @@ -543,6 +543,7 @@ static struct edid *ps8640_bridge_get_edid(struct drm= _bridge *bridge, > struct drm_connector *connecto= r) > { > struct ps8640 *ps_bridge =3D bridge_to_ps8640(bridge); > + struct device *dev =3D &ps_bridge->page[PAGE0_DP_CNTL]->dev; > bool poweroff =3D !ps_bridge->pre_enabled; > > if (!ps_bridge->edid) { > @@ -574,6 +575,11 @@ static struct edid *ps8640_bridge_get_edid(struct dr= m_bridge *bridge, > connector->s= tate->state); > } > > + if (!ps_bridge->edid) { > + dev_err(dev, "Failed to get EDID\n"); > + return NULL; > + } > + > return drm_edid_duplicate(ps_bridge->edid); > } > > -- > 2.40.0.348.gf938b09366-goog > Reviewed-by: Robert Foss