Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp492616pxa; Wed, 12 Aug 2020 07:11:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt+WdSYHziE78yu7C2wH9jLmQ5+ySsl3brIijPx6k6Im8x8uW9Mt/S6up7oCDYplRvT5Ud X-Received: by 2002:a05:6402:2069:: with SMTP id bd9mr75618edb.127.1597241480767; Wed, 12 Aug 2020 07:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597241480; cv=none; d=google.com; s=arc-20160816; b=EQCeIQQFYMESw8z0deMkrHkiZgodX+zy4xufwIzcuAO6FgDAn2pVOaOjjWeZk11A+w h3tS1ePzcvgPdF/ZvZGTYui3pzvMoWX7T5xC/a2PfxjuDMx3gJeNHEvLlAZ71wpVDejL 0Z772FWpytTid95gNb/A3VsACYs46qTQMRf/MWPV5YtGpCCunHYh2xBvReAQ+t3RcW79 k6Jw6fBalO/a6uS3Olkr4TkG5b6dtjvX7O7toUPhs5jk60n0l/jmTLYPdHdSSuhT5qa4 Uwufj0jOQYtiBm5qhL9W1aluz9A09AfWts92nPWGjRGNrvQ9orT5BvqggUf7RJYjvznB DTWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fQpYDgkPY9yLnBp0UJp8jvJUvHu94wXm2Rvd4KAL1+8=; b=a1Twg6t85MX1H1uDCIEt2HoBqu4U5g3dzKqqpSJ54LcukjxjfUAht43N8zeBziQzHL k22iiuEk8kYiqIAnjIPGBspObWmEPdKNOan2zhFJxUhx0yQQYVe9vQ2wLADmiMN/wPVt 40GOBCnlTHAhhaj4f6weOJac9go3D3IglY+GuVhmQTMvvnMwnn38JoUaw+LxMpOeLBHQ CISu7JwuXfI6uM3tkDVj5gwU5GmPiykCuQDoI0r9gp++UQWoewqns69N5KK3xMbGc7OU vEM3zXOf3JGf3KdOvyLWOucBzmp8/KDXswkkyYDSKJMiz2lFigpJsuJTMIpU3W28+XBk DsRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=MYObIKtE; 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 b9si1324905edn.499.2020.08.12.07.10.57; Wed, 12 Aug 2020 07:11:20 -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 header.i=@ffwll.ch header.s=google header.b=MYObIKtE; 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 S1726542AbgHLOKX (ORCPT + 99 others); Wed, 12 Aug 2020 10:10:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbgHLOKU (ORCPT ); Wed, 12 Aug 2020 10:10:20 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3948C061383 for ; Wed, 12 Aug 2020 07:10:19 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id u24so782394oic.7 for ; Wed, 12 Aug 2020 07:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fQpYDgkPY9yLnBp0UJp8jvJUvHu94wXm2Rvd4KAL1+8=; b=MYObIKtEhualdDLE4KCuFf0k1rLOTRrmO/XY5GYjlct7s5zBj12CSi+TCHJKcq43Em iA2ub8UeRKVY23cHauGk+Fq1eqbGYFEELgT0rbSVhgvH4eSGBNDiY7z5P3QzrhhhpH1a f4Z0XIXeu2yLjoFhKHpwiKFUkNopB75wb/ZHA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fQpYDgkPY9yLnBp0UJp8jvJUvHu94wXm2Rvd4KAL1+8=; b=N7saLJRMvedKeSkHYm15ySpINDA5LlKo3BYXqdF5iROvUYV5owXnW2MyNzpJOrCEgv nRav+7rSH8nnJYJjKIAJqF8SiniU6uIQ405vN6snNh3U0SKEWRPmkgo9f8yJrL4Kc62n VlcEVXj6aja667JDPtZxTIwCOJmtgu9H502PX4lZIhQPJV3iOn36MMH/TydI7TgAI5dg 2RbquGJLGaCEtWY+3T1kO8yAT7KeqtSwEcIjjLeJFJWWtUbwyFv8HIPTVBD0hFNy7Fe/ 0bLdFE/yju/Yviz18cDqBx2v4HkLoqogXFBi6gwXV6wCL8+YqybiBNQoWqhTuzBTqJ/Q 5w5w== X-Gm-Message-State: AOAM533pQl3+a67lNk1c/JOtnXKiOqIOdWTiHWgYKPnTso0HHO4w8spI Qq+sPrDSri44ZxiIxUo13PR6vDIDGStdJvN2ATH6/w== X-Received: by 2002:aca:88a:: with SMTP id 132mr6823888oii.101.1597241419407; Wed, 12 Aug 2020 07:10:19 -0700 (PDT) MIME-Version: 1.0 References: <20200811085830.GZ2352366@phenom.ffwll.local> In-Reply-To: From: Daniel Vetter Date: Wed, 12 Aug 2020 16:10:08 +0200 Message-ID: Subject: Re: [PATCH] drm: assure aux_dev is nonzero before using it To: Zwane Mwaikambo , Lyude Cc: tcamuso@redhat.com, dkwon@redhat.com, Linux Kernel , dri-devel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 12, 2020 at 12:16 AM Zwane Mwaikambo wrote: > > On Tue, 11 Aug 2020, Daniel Vetter wrote: > > > On Mon, Aug 10, 2020 at 10:11:50AM -0700, Zwane Mwaikambo wrote: > > > Hi Folks, > > > I know this thread eventually dropped off due to not identifying > > > the underlying issue. It's still occuring on 5.8 and in my case it > > > happened because the udev device nodes for the DP aux devices were not > > > cleaned up whereas the kernel had no association with them. I can > > > reproduce the bug just by creating a device node for a non-existent minor > > > device and calling open(). > > > > Hm I don't have that thread anymore, but generally these bugs are solved > > by not registering the device before it's ready for use. We do have > > drm_connector->late_register for that stuff. Just a guess since I'm not > > seeing full details here. > > In this particular case, the physical device disappeared before the nodes > were cleaned up. It involves putting a computer to sleep with a monitor > plugged in and then waking it up with the monitor unplugged. We also have early_unregister for the reverse, but yes this sounds more tricky ... Adding Lyude who's been working on way too much lifetime fun around dp recently. -Daniel > > > > > > > > To me it still makes sense to just check aux_dev because the chardev has > > > no way to check before calling. > > > > > > (gdb) list *drm_dp_aux_dev_get_by_minor+0x29 > > > 0x17b39 is in drm_dp_aux_dev_get_by_minor (drivers/gpu/drm/drm_dp_aux_dev.c:65). > > > 60 static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor(unsigned index) > > > 61 { > > > 62 struct drm_dp_aux_dev *aux_dev = NULL; > > > 63 > > > 64 mutex_lock(&aux_idr_mutex); > > > 65 aux_dev = idr_find(&aux_idr, index); > > > 66 if (!kref_get_unless_zero(&aux_dev->refcount)) > > > 67 aux_dev = NULL; > > > 68 mutex_unlock(&aux_idr_mutex); > > > 69 > > > (gdb) p/x &((struct drm_dp_aux_dev *)(0x0))->refcount > > > $8 = 0x18 > > > > > > static int auxdev_open(struct inode *inode, struct file *file) > > > { > > > unsigned int minor = iminor(inode); > > > struct drm_dp_aux_dev *aux_dev; > > > > > > aux_dev = drm_dp_aux_dev_get_by_minor(minor); > > > if (!aux_dev) > > > return -ENODEV; > > > > > > file->private_data = aux_dev; > > > return 0; > > > } > > > > > > > > > _______________________________________________ > > > dri-devel mailing list > > > dri-devel@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch