Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp786713pxy; Thu, 22 Apr 2021 13:27:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzmzD6Uqr8cfFHsWWmZu7XqoJm0mb5Tiw8IkhbDJMg1CoWOjXz3nY0tPnjKc/z1f0c0iNo X-Received: by 2002:a62:81c4:0:b029:257:cf19:2f02 with SMTP id t187-20020a6281c40000b0290257cf192f02mr411132pfd.50.1619123255793; Thu, 22 Apr 2021 13:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619123255; cv=none; d=google.com; s=arc-20160816; b=qRQ++3zQQ4WsyMdYcHSUHLxNQN766HNKEHsWlXdy0boF0jKVOgz/t340sczHLGuTR6 7ikiDRwMcsiWXy+dx+yEOTB/vIcS6mEPB3LwpxJC2h8qrp4/m+4Yy08XjLbn/u08eQ9Q HyXqnEq8drZr0e1xKexJyrTwE1YZNTIZceUXaXfX4RzAwPVibZwTukRMOBnQL4Ud5BTs 8blQv/VaigKjzR2PhcKmukRmzrQVkHoSDBwuMlYaN/nfxxSr2atNZqlL076cfZCJFqRe peWaY3diZct5+Cb0F+FGllsYDx4LkiZB8ckgkKCaNwg4LmQvmZsEgD6gyDWwXNqxoCHM dZjw== 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 :message-id:date:subject:cc:to:from; bh=cKXrzZP/RsvbbObPI65HwyC36LKlACISYIANe2Xh80Q=; b=GLJ9RFv1c67O+Gfv2BPW15ipzmvYr+6erUVKIp97ktyYeBqhnT2srLAMGYVhkLVs30 6jT2RcSXYOMGLC0aCaGRrO44lo9iLPukAV3v+Ux5TajVKElbApvUtDf/YJu5LAJl+rJL NQ+S5pmhrTKeRSMBjTxALbQzKJ6tNr6qizE0kHan3XtgVH0F5pXd5FHZNHOAGZCIJ40a GUzHraxYiUbAtkb58V8wBtzT+tSqRsERGEvLpNxfDF2RO7x8GDUqYjbRCEHflQJLcjGA 6yXzYDNgyxJt1UpHuD+ouTS0NrDVIteS24Sai5YCxQjSF6qx0qlrtkyuO/3qlXXrati0 e3GA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si4206200pfi.169.2021.04.22.13.27.23; Thu, 22 Apr 2021 13:27:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237030AbhDVU0N (ORCPT + 99 others); Thu, 22 Apr 2021 16:26:13 -0400 Received: from smtpout1.mo528.mail-out.ovh.net ([46.105.34.251]:40769 "EHLO smtpout1.mo528.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236949AbhDVU0M (ORCPT ); Thu, 22 Apr 2021 16:26:12 -0400 X-Greylist: delayed 429 seconds by postgrey-1.27 at vger.kernel.org; Thu, 22 Apr 2021 16:26:11 EDT Received: from pro2.mail.ovh.net (unknown [10.108.16.12]) by mo528.mail-out.ovh.net (Postfix) with ESMTPS id AED6BA1BA55D; Thu, 22 Apr 2021 22:18:26 +0200 (CEST) Received: from arch.lan (89.70.221.198) by DAG2EX1.emp2.local (172.16.2.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 22 Apr 2021 22:18:26 +0200 From: Tomasz Duszynski To: CC: , , , Tomasz Duszynski Subject: [PATCH] iio: core: fix ioctl handlers removal Date: Thu, 22 Apr 2021 22:14:15 +0200 Message-ID: <20210422201415.46378-1-tomasz.duszynski@octakon.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [89.70.221.198] X-ClientProxiedBy: DAG1EX1.emp2.local (172.16.2.1) To DAG2EX1.emp2.local (172.16.2.11) X-Ovh-Tracer-Id: 15713622053141568535 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrvddutddgudegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvufffkffoggfgtghisehtkeertdertddtnecuhfhrohhmpefvohhmrghsiicuffhushiihihnshhkihcuoehtohhmrghsiidrughushiihihnshhkihesohgtthgrkhhonhdrtghomheqnecuggftrfgrthhtvghrnhephedtgefgkeduvdekheeggefghffhteekleetvdekvddtveeutdetueefueehieetnecukfhppedtrddtrddtrddtpdekledrjedtrddvvddurdduleeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhrohdvrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepthhomhgrshiirdguuhhsiiihnhhskhhisehotghtrghkohhnrdgtohhmpdhrtghpthhtoheplhgrrhhssehmvghtrghfohhordguvg Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Tomasz Duszynski --- 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