Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1153124pxy; Fri, 23 Apr 2021 01:13:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxonW4jdrT633YJe/gMQc4pG1iNqa2kG7omKEKsL8VhqjIpZT0H4nlUsPyNhpatRUKK+V1 X-Received: by 2002:a65:6407:: with SMTP id a7mr2650286pgv.352.1619165634558; Fri, 23 Apr 2021 01:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619165634; cv=none; d=google.com; s=arc-20160816; b=psKqwKNqnyD8HxCZ6nUd0QiIxuJUSdgBh47oVDWaWP8V9pCvYQQA+kNWSfQt2MaRLI l4btRQzM/NTk1hezfOPcOsh1g2hioow301ZoSO35YafSmypZFBFCLsk1bHy6SDSxyGYY PCDMPIdP9323gUW+6mexh85YSSd46WaOUN9Y7ZirFfO/A1yPoy4u662tQj7WXAC/xfCs xuwcfJx/3Oq0Gn5utBFzZOfGzD0Eu5U3rE5NR9Q5iuCHT46mWQX2vG9J2HMs2qynyBHd cF3wqsvebV6R+orBH/Oj5cpwXOs6SuenkPvwTAFcr4vMV3Qmsux08hLyjJZwwsn+4fDW rBlQ== 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=QEUG5ayAL06z95hzrUYvBWYVUQrSs1UikPpnZCfERWk=; b=0tNQfe9BOp+oGXmJf+i+Lqor3gDrvKEUj1ntbskOnH9f4G2vFo9nSKHWJbaVsJZedL vM06dyfMQZQLY7V0HLTWSJbxH8CY5XjL8xfvqOmpBYob9WOYx+GyFcS0h8rbqFx0BbHa +3v1JzmnRQTaA9q4UvBLb7iUfjKvdbisoBVtotkqPRb3OjN2R5RVFTKd28DLH8NpoHca iT6uZGGp2KPhxPvMMlQZb3nGr8s6I5DM89ncMZxj7UkOaVl5WSYX+pwdb/sAUbb5l7vh i116rdz/LRoNezsuQd7A8F5Bfrv3VJmFO2mJN2S/33xh/4PwJ8GNfTZ8gOfxszLIR0Ka nV9w== 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 u19si5760413pfh.285.2021.04.23.01.13.42; Fri, 23 Apr 2021 01:13:54 -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 S241333AbhDWINp (ORCPT + 99 others); Fri, 23 Apr 2021 04:13:45 -0400 Received: from smtpout1.mo3004.mail-out.ovh.net ([79.137.123.219]:37893 "EHLO smtpout1.mo3004.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241147AbhDWINn (ORCPT ); Fri, 23 Apr 2021 04:13:43 -0400 X-Greylist: delayed 374 seconds by postgrey-1.27 at vger.kernel.org; Fri, 23 Apr 2021 04:13:42 EDT Received: from pro2.mail.ovh.net (unknown [10.109.138.36]) by mo3004.mail-out.ovh.net (Postfix) with ESMTPS id ED1D223DA17; Fri, 23 Apr 2021 08:06:51 +0000 (UTC) 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; Fri, 23 Apr 2021 10:06:51 +0200 From: Tomasz Duszynski To: CC: , , , , Tomasz Duszynski Subject: [PATCH v2] iio: core: fix ioctl handlers removal Date: Fri, 23 Apr 2021 10:02:44 +0200 Message-ID: <20210423080244.2790-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: CAS2.emp2.local (172.16.1.2) To DAG2EX1.emp2.local (172.16.2.11) X-Ovh-Tracer-Id: 9231253336844360727 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrvdduvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvufffkffoggfgtghisehtkeertdertddtnecuhfhrohhmpefvohhmrghsiicuffhushiihihnshhkihcuoehtohhmrghsiidrughushiihihnshhkihesohgtthgrkhhonhdrtghomheqnecuggftrfgrthhtvghrnhephedtgefgkeduvdekheeggefghffhteekleetvdekvddtveeutdetueefueehieetnecukfhppedtrddtrddtrddtpdekledrjedtrddvvddurdduleeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhrohdvrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepthhomhgrshiirdguuhhsiiihnhhskhhisehotghtrghkohhnrdgtohhmpdhrtghpthhtoheprghruggvlhgvrghnrghlvgigsehgmhgrihhlrdgtohhm 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. Fixes: 8dedcc3eee3ac ("iio: core: centralize ioctl() calls to the main chardev") Signed-off-by: Tomasz Duszynski Acked-by: Alexandru Ardelean --- 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