Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp786082pxa; Tue, 11 Aug 2020 15:17:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3BkI4I/u9/zY0Qfh8ancovYExfsyeNKtGT+K1OuM7GumpR9LfW5YDeabN7eqSOhr3qm4I X-Received: by 2002:a17:906:2749:: with SMTP id a9mr28224885ejd.28.1597184271181; Tue, 11 Aug 2020 15:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597184271; cv=none; d=google.com; s=arc-20160816; b=jMp6whF+Ymfkwo8lP9wG0U47PR7nEoSeN995SaNtKnhg5XCkXWxrXqF2KmcrxCbSvz W//5NVVIxPgvLBpip0z1vfnaUtSLA2CIuQBNPALvGqiJkPEsf2gucK8NcqJNii5QAnF9 HTvNU6Su3d/G9xGhF0j9nnAudRgNMY2wFVM1dvKE/EoX6NqvPLHdt7nqrnBM03dc1uH3 MJtgBlcUCRLW/hiRg4L3UIEwhuFZLs0aZ+EV8kKnXdM9U1ZqzbFb6B+Aj2a2ikwyWsNH 4Ju0FElgWH7X5Rn6QR/MQUQOfT5BL7YR/VzlQe6Jw7zxy6TSN8OmePKUGSNBbk9SY7tr toyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=PY9oREIA5BEL9rDwaiWimBEh7thLB86kg6qWZqtH/rQ=; b=0S1q99I5Jv1xPP9DefvEd2/ZOQ6P2uG6NnIyGXopZ1PyxRXPEN3GyvGyG+ixOuQdP0 PD6h3AH57SMIZLTZhkcCAfBLYXNZX19XlE7/UUHu5qk99SL8SeC8GYSnRa0fNoUxj79z spa/PmbKP2gkPfP4nvwNe4q2zj+OLf538r2Zf/rejK49K0jqmQuoeM8iuTNRyCzDm5jo 7Z0//FsyY4C4DKs3PGdYHfmhW6jodJwvpmhxKnD9Uk5iTZOY/Yt56SZdpo1YkraAazbO KvzDpaOar5hWQMqJtJ5DcCW7FCAjaMPz3mcW0pjHqZLX6vuSvnIEHb9Rla7cLyaL4uxD 822Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd28si44067edb.460.2020.08.11.15.17.26; Tue, 11 Aug 2020 15:17:51 -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; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbgHKWQt (ORCPT + 99 others); Tue, 11 Aug 2020 18:16:49 -0400 Received: from cmta19.telus.net ([209.171.16.92]:35830 "EHLO cmta19.telus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbgHKWQs (ORCPT ); Tue, 11 Aug 2020 18:16:48 -0400 Received: from montezuma.home ([154.5.226.127]) by cmsmtp with SMTP id 5cZXkg9CWpULu5cZYkCNXh; Tue, 11 Aug 2020 16:16:47 -0600 X-Telus-Authed: none X-Authority-Analysis: v=2.3 cv=T9TysMCQ c=1 sm=1 tr=0 a=f8b3WT/FcTuUJCJtQO1udw==:117 a=f8b3WT/FcTuUJCJtQO1udw==:17 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=COSDN44dAAMA:10 a=e5mUnYsNAAAA:8 a=7LT71PhNQJGCqy_fO74A:9 a=CjuIK1q_8ugA:10 a=Vxmtnl_E_bksehYqCbjh:22 Date: Tue, 11 Aug 2020 15:16:43 -0700 (PDT) From: Zwane Mwaikambo To: Daniel Vetter cc: tcamuso@redhat.com, dkwon@redhat.com, Linux Kernel , dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm: assure aux_dev is nonzero before using it In-Reply-To: <20200811085830.GZ2352366@phenom.ffwll.local> Message-ID: References: <20200811085830.GZ2352366@phenom.ffwll.local> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfM7P2Qveb9f03hcrnn/yURgCyHfwV6v+s0PERnrykmqUT9nIDFaYZca86P7MhymuDfMJ8Dft8ITHy7q8RytlH7vlQSIZSejlytm13CeLcq/mMelBiApu y1TTYNtKCJ3Q/v2pncXORY17OTSUGFaloe8dt7NV8Wq1vj9jLDnpoq4wyyV/kSdE+CczOlN4IhiiFlo2Dh8yJcWP93bErXIkEArHtGERwrKsXGQl5d2lK0XW x50GKKcuU6FBvyR2xKvixQevQ4Vu39luQkhZOHO4NYGtFQj7qrjElt44L3H4n8Yq9StF7F1YIVq9M5YDX7S95Q== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > > > 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 > >