Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp668443pxj; Thu, 17 Jun 2021 11:01:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDXgSARwUmUebK8Uh1gnguXWEU3HfKB1VfMAGoduYzK4SO4tbWadUVn31w9sh2wHS4OVvZ X-Received: by 2002:aa7:db52:: with SMTP id n18mr2718816edt.170.1623952901637; Thu, 17 Jun 2021 11:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623952901; cv=none; d=google.com; s=arc-20160816; b=a5B/tooIazZfpvN5jpnqJCb9/DGMH7dASScmEm3V3TE8db7YJ9nfOp7039J1avUgQy hapGfjpMA0qMH4JYizqTOl8W7zaq1axMhJR4kWs8h/7PjFCm0sy+FmL6hTlZYxRu85KZ c7YO3Gkxdw6h0/rt5222KDjJs9FEL3fgq/cShDqGw9zaEizC5rq4rAKqfzIdwOOMC9HZ CesKLKhIhiHOrVvJKkP8ycNhxBoQrVVVLm3nNH/Lm74BcMVuAxkmwAo/uQXURwVp4qup jX9SYu8Vr1+p40MD/ZS9rOf5/YKBX1IcsJI1QxiV1Zp2JpoBsfWV789yFdpM5VNdFid/ 3lJg== 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=vVVOSWHykppJbIwjIJuVP0crPjm6QB4sy9hXPtbRixg=; b=fn/+h4Sjz+t/9aO3tYpk26O0vc5gn3DgwNk3W7zxxaexjjFnjk9YFYWQrpecZwN5Tv Xy2HJG7duOM6+A3eupiRKG3BpRQQ1mS9ZNvN6Ky/zrO8pHBME/Rr5ii25KLd8DdKCGIn RinUVtZRQCF+QlsKzt3rh8t+4/dD9sxZx70CFgPFqZeXv/Dn+N9a8xBHDZcux7OD1//O XhdVj+L9DjaJknRr5jluJXMaKnI1MOZ3nuoBmVmHm2axDp7t2S6XHWKdjY4VOhm75DPi ixfDSWJLFt8r66xhDit6PEBW1kXorBovA6CqUL4Blre2nUzJUknaOSqJbNsKpMAURbsV 5WwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Xr1iuQiF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si6249081ejj.375.2021.06.17.11.01.18; Thu, 17 Jun 2021 11:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Xr1iuQiF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbhFQOQ0 (ORCPT + 99 others); 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