From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EDD9C2B9F4 for ; Thu, 17 Jun 2021 14:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CA6C61249 for ; Thu, 17 Jun 2021 14:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhFQOQ0 (ORCPT ); Thu, 17 Jun 2021 10:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbhFQOQZ (ORCPT ); Thu, 17 Jun 2021 10:16:25 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A5F6C061574 for ; Thu, 17 Jun 2021 07:14:18 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 944B6E7B; Thu, 17 Jun 2021 16:14:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1623939256; bh=hF29H5G9lOwa6KnCuMQqI5VpXy3ivxjr+tXdvvRfXTM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xr1iuQiFQN0JP+F1bWWhREP4z4ue0UrpoU6ZSoZgKA3hFvBNRBJImfRiXk3ULE5Tr MbMwi1y2cYYD3Yytq6G6kGQM/3uENT5NFqnFbWbenJy0pqjPeLon7Y1mLhY4UkWC+t 4e8Uk7cjhFo+VgpieMuOtgU5nViwE69/w5kwdLYQ= Date: Thu, 17 Jun 2021 17:13:53 +0300 From: Laurent Pinchart To: Jonathan Liu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andrzej Hajda , Neil Armstrong , Robert Foss , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Linus Walleij , Marek Vasut , Frieder Schrempf Subject: Re: [PATCH] drm/bridge: ti-sn65dsi83: Fix null pointer dereference in remove callback Message-ID: References: <20210617111925.162120-1-net147@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210617111925.162120-1-net147@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, Thank you for the patch. On Thu, Jun 17, 2021 at 09:19:25PM +1000, Jonathan Liu wrote: > If attach has not been called, unloading the driver can result in a null > pointer dereference in mipi_dsi_detach as ctx->dsi has not been assigned > yet. Shouldn't this be done in a brige .detach() operation instead ? > Fixes: ceb515ba29ba6b ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver") > Signed-off-by: Jonathan Liu > --- > drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c > index 750f2172ef08..8e9f45c5c7c1 100644 > --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c > @@ -671,8 +671,11 @@ static int sn65dsi83_remove(struct i2c_client *client) > { > struct sn65dsi83 *ctx = i2c_get_clientdata(client); > > - mipi_dsi_detach(ctx->dsi); > - mipi_dsi_device_unregister(ctx->dsi); > + if (ctx->dsi) { > + mipi_dsi_detach(ctx->dsi); > + mipi_dsi_device_unregister(ctx->dsi); > + } > + > drm_bridge_remove(&ctx->bridge); > of_node_put(ctx->host_node); > -- Regards, Laurent Pinchart