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 4C69F335547 for ; Mon, 26 Jan 2026 17:04:16 +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=1769447056; cv=none; b=fNxo2Q8IHHLffOvapLOPu/cchfkZkBbgXBXJy/rWCIe7CwbA0/Rt8iyyPkxxtb9GL8YGb4NrEbFjyJGWhy8iQJTBgjyY/zgSqRijvw0DTp7phmaX2lT/xa1GdzdQfeZ7/yAP9nGGIdvwPA8hFzY/LQegO25jhyuDWn9udQjxcSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769447056; c=relaxed/simple; bh=Nsgbiykaiv6wE8HrML3RAW32X13gMc9lRhsI1qNkY0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MN7xkKD6EbpaoLlaLJcMhziWOiQR5op9EixJ6iYFR3lJi6yXktm1/r0RXXgwH8+Yn53qmlL7ILLQSOA5haWaMkBoqIoHeDCDrmRsbIYmvzpXe8Cl6dT/Z+G39r3lu5z1EImdZ2+b08ld/d01YYrQFc0kFV0GVzvK3Az7fqc9+PM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eXpvRFC4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eXpvRFC4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EDD9C116C6; Mon, 26 Jan 2026 17:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769447055; bh=Nsgbiykaiv6wE8HrML3RAW32X13gMc9lRhsI1qNkY0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eXpvRFC452Oq7GtppU2tFKjMik55qtzbaWkBB8JwXk3I7BeFj74CteOCfPtFa8aow byCSATi6TmU0k02FxwaVWj1Rc8tmpjYzrTxUGUPzCNsvIth7jZyUsvHGyvplwbFdLn 1HPpxmjaTlQTd+6VRkgzf+uQxwVamVbaAaOLwuMMTbLxBBjlLbSu9c/edWnA8+KdIt oNDnabHTFuRwXTpGkrBbWnlrQ2ZdDKTp2YrqM1IH1dNDEpUNt4ZaO9DCZ4botzWAST zVwxEULph/3SWSZ1cmPBWCBHNkmpHjxUG3xKrAFejb6ayFVxQkM+v+jRz+ysuLZ7Ef ImBkanG4lG1Vw== From: Sasha Levin To: stable@vger.kernel.org Cc: Andy Shevchenko , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.12.y 1/3] iio: core: add missing mutex_destroy in iio_dev_release() Date: Mon, 26 Jan 2026 12:04:11 -0500 Message-ID: <20260126170413.3418184-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026012655-stipend-xbox-ead1@gregkh> References: <2026012655-stipend-xbox-ead1@gregkh> 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 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 --- drivers/iio/industrialio-core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 6a6568d4a2cb3..43b842a062271 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1628,6 +1628,9 @@ static void iio_dev_release(struct device *device) 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); @@ -1672,8 +1675,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) 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); @@ -1696,6 +1698,9 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) 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); -- 2.51.0