From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBDB22D8379; Wed, 28 Jan 2026 15:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769614737; cv=none; b=l7YO+5jU1gR/hloGY/Ied+K+bASoETj8VnU3EWQE+/+o0ACDxcxsOupkYVpr8YQqXrIpkei1l2B1RrqKbY4oU7VUkWsOUuGR1LOSaXYkC7ztuBVosVJku1PbmLsh+k+uNYtHiT0WwMDgFcD7MiooPENJ5PCOSJRWDRMsOFr/0rI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769614737; c=relaxed/simple; bh=v+2CqRmAWaf3ZfTqjBoxrv5Ltbs8BJnoNCKEqXi+Dos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hUbKxxY4x/H3SEHtjrkRUQPGmMr0j2AZbFwgLJhXhuiimbUrvSYmXyPGaxOXp4cAcxx/25yGnn93g3XKYxwl6qJ6n6dJUHVSIJPmghtKpMubAyrMC1sp7barosPWPObny7Q9rVRDR19wKr2elt57fhSlDJuMI1bhx1q+r/6sRSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wpVg7nuk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wpVg7nuk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C692C4CEF1; Wed, 28 Jan 2026 15:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769614737; bh=v+2CqRmAWaf3ZfTqjBoxrv5Ltbs8BJnoNCKEqXi+Dos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpVg7nukRNkRgBPVvCr9vtEnqFhm9qY6l3lO5L4HZ8mTZGyMmPtDExwOx/HgUdmav i79L4gUl4BU/7VHPOAADJJuIrzllbSxnlIYUZDDPyqYfe19fuI1aX/uoXyqbpVWPfD j5yWHincxrnwYhL9qFiToPVDfhE9Xl6EsgonWgfc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andy Shevchenko , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.6 227/254] iio: core: add missing mutex_destroy in iio_dev_release() Date: Wed, 28 Jan 2026 16:23:23 +0100 Message-ID: <20260128145352.954560583@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260128145344.698118637@linuxfoundation.org> References: <20260128145344.698118637@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Shevchenko [ Upstream commit f5d203467a31798191365efeb16cd619d2c8f23a ] Add missing mutex_destroy() call in iio_dev_release() to properly clean up the mutex initialized in iio_device_alloc(). Ensure proper resource cleanup and follows kernel practices. Found by code review. While at it, create a lockdep key before mutex initialisation. This will help with converting it to the better API in the future. Fixes: 847ec80bbaa7 ("Staging: IIO: core support for device registration and management") Fixes: ac917a81117c ("staging:iio:core set the iio_dev.info pointer to null on unregister under lock.") Signed-off-by: Andy Shevchenko Reviewed-by: Nuno Sá Signed-off-by: Jonathan Cameron Stable-dep-of: 9910159f0659 ("iio: core: add separate lockdep class for info_exist_lock") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iio/industrialio-core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1618,6 +1618,9 @@ static void iio_dev_release(struct devic iio_device_detach_buffers(indio_dev); + mutex_destroy(&iio_dev_opaque->info_exist_lock); + mutex_destroy(&iio_dev_opaque->mlock); + lockdep_unregister_key(&iio_dev_opaque->mlock_key); ida_free(&iio_ida, iio_dev_opaque->id); @@ -1663,8 +1666,7 @@ struct iio_dev *iio_device_alloc(struct indio_dev->dev.type = &iio_device_type; indio_dev->dev.bus = &iio_bus_type; device_initialize(&indio_dev->dev); - mutex_init(&iio_dev_opaque->mlock); - mutex_init(&iio_dev_opaque->info_exist_lock); + INIT_LIST_HEAD(&iio_dev_opaque->channel_attr_list); iio_dev_opaque->id = ida_alloc(&iio_ida, GFP_KERNEL); @@ -1687,6 +1689,9 @@ struct iio_dev *iio_device_alloc(struct lockdep_register_key(&iio_dev_opaque->mlock_key); lockdep_set_class(&iio_dev_opaque->mlock, &iio_dev_opaque->mlock_key); + mutex_init(&iio_dev_opaque->mlock); + mutex_init(&iio_dev_opaque->info_exist_lock); + return indio_dev; } EXPORT_SYMBOL(iio_device_alloc);