Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp2053332pxy; Sat, 24 Apr 2021 03:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7t7q4aTUndaEJO8nfAi8IlkAUV/6h1Z+b9tDIA+2FaRNLsBAyLw8D/Re8Rfzo6Rwz43LH X-Received: by 2002:a63:e209:: with SMTP id q9mr7825718pgh.372.1619261577781; Sat, 24 Apr 2021 03:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619261577; cv=none; d=google.com; s=arc-20160816; b=LTz6zaCRngBpZIh5hEyFASK6sBs//N319TR+1Ut/A8zft8P3jdGmU3doFZv9MNb/zU m4Cn9df/gSJvYFifGu9TzJcTMjy/w3yL3vC1NT8j1K8TL/+vs8llNajKx1xbmbQ37Jwx qSvTsGetkx4+HkgiYxk0vKo+uJaEz12QX6RGRTzCh+2M+T1vArqnpq7KB1T8iMJ5DByV BUhj8srH3YhhYOoIdHNFC7RrZTveNyhUWQN52JrrOb8NgIH+jJzW0caP2msl9eapH1QU 55oG4jMIv17cKCEC1EA6AfCYt6b7TxXeytkAsyxmmImTHvuSisrZ8OhHX7qc3mA703HS 5w2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Y9wDTQglt7E6Tm23V+akT2yLPkbAXRO67YvG51QOLpo=; b=d3Pynjm+V/FtKuk/JGyQZ6zXb3cIgq/SlJFPFGNMEVG5FYpVeiOz9492Pmwh8c37f7 iVSboo5yidE1hGf+PJYBTbbofyFENbOWJ28zOq0pTvAUYCuT+Cdnqa3gdFK/M71G9N7G uDbKAt3aF7eSga5ddxqqV9PkOQP5xVULP2fuyKm+LUsYTgBwT9dyUuLRKeDCfROk9gFn TmHln0ovw8c91gvxS6vU5bKw+M49VgrWYVnmCq+MRHf8dj5TYmOOZxBX3Qjc0ufizQkq fB3XCBMkWsS4SQO8Jjs39BY/AieRwFtsZBK18d7I6Mmi60hBYG0h801a6cCVDX/WMHyc 9fmA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si12519849pfv.143.2021.04.24.03.52.45; Sat, 24 Apr 2021 03:52:57 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235023AbhDXKww (ORCPT + 99 others); Sat, 24 Apr 2021 06:52:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:53446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbhDXKwt (ORCPT ); Sat, 24 Apr 2021 06:52:49 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0CB1E61396; Sat, 24 Apr 2021 10:52:09 +0000 (UTC) Date: Sat, 24 Apr 2021 11:52:50 +0100 From: Jonathan Cameron To: Tomasz Duszynski Cc: , , , Subject: Re: [PATCH v2] iio: core: fix ioctl handlers removal Message-ID: <20210424115250.14d21a71@jic23-huawei> In-Reply-To: <20210423080244.2790-1-tomasz.duszynski@octakon.com> References: <20210423080244.2790-1-tomasz.duszynski@octakon.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 23 Apr 2021 10:02:44 +0200 Tomasz Duszynski wrote: > Currently ioctl handlers are removed twice. For the first time during > iio_device_unregister() then later on inside > iio_device_unregister_eventset() and iio_buffers_free_sysfs_and_mask(). > Double free leads to kernel panic. > > Fix this by not touching ioctl handlers list directly but rather > letting code responsible for registration call the matching cleanup > routine itself. > > Fixes: 8dedcc3eee3ac ("iio: core: centralize ioctl() calls to the main chardev") > Signed-off-by: Tomasz Duszynski > Acked-by: Alexandru Ardelean There are a bunch of unused local variables as a result of this change (build warnings on my standard W=1 C=1 test). I've dropped those as well and applied this to the fixes-togreg branch of iio.git. We are a bit unfortunate on timing for this as I won't send a pull request for fixes until towards the end of the merge window. I've marked it for stable though so it should filter back fairly quickly so kernels people actually use. Thanks, Jonathan > --- > v2: > * add fixes tag and ack > > drivers/iio/industrialio-core.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index d92c58a94fe4..98944cfc7331 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -1939,9 +1939,6 @@ void iio_device_unregister(struct iio_dev *indio_dev) > > indio_dev->info = NULL; > > - list_for_each_entry_safe(h, t, &iio_dev_opaque->ioctl_handlers, entry) > - list_del(&h->entry); > - > iio_device_wakeup_eventset(indio_dev); > iio_buffer_wakeup_poll(indio_dev); > > -- > 2.31.1 >