From patchwork Thu Oct 19 07:35:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 736471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A41FDCDB465 for ; Thu, 19 Oct 2023 07:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232840AbjJSHfo (ORCPT ); Thu, 19 Oct 2023 03:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbjJSHfo (ORCPT ); Thu, 19 Oct 2023 03:35:44 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2A28112; Thu, 19 Oct 2023 00:35:38 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 8D6016000C; Thu, 19 Oct 2023 07:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697700937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HucUa7dgW0DX1NhXf/pL0MQyRjRhnDgkYcJwUZwxjWk=; b=jrY5dLO4jlBtMYtXAx/nk+Ge51PUZWvldB7hHUAz+GJ/vtaUgDGQz93hBus1jRJ7750SEL jAnL0dcCY4zs8aB6Z7NWef2hiQqUBbgawv9Q3Q8PblKEurojjhFLc2AyppXU6sc/uJGKX6 xKJMz2+MQ3+Y9sG677DISz+7xHmZPSnFp7banlYtL0UAzqMiuJZSJv/jSyREnzeJ8kuH9A blAZOInMNxON6K2qIwfxDNS7rfgns/bM34WpgRMYEfoxid98Hgdw5S5Z3ktU1V2yDDPvKx 56015eKCvOVjTKpRJO/HUrkqYSdNR36eQKyNMyZkC4frbDgJkRASLT/7eQT8Yw== From: Herve Codina To: Wolfram Sang , Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH 0/3] Fix i2c mux module refcount issues Date: Thu, 19 Oct 2023 09:35:27 +0200 Message-ID: <20231019073533.386563-1-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Hi, Some i2c mux drivers wrongly use the pair of_find_i2c_adapter_by_node() / i2c_put_adapter() to lock the parent adapter. Indeed, i2c_put_adapter() decrements the module refcount while of_find_i2c_adapter_by_node() does not increment it. This leads to an overflow over zero of the parent adapter user counter. Identified mux drivers impacted are: - i2c-mux-gpmux - i2c-demux-pinctrl - i2c-mux-pinctrl Commit 48e9743dd648 ("i2c: core: add and export of_get_i2c_adapter_by_node() interface") introduces of_get_i2c_adapter_by_node() to correctly handle this refcount issue. This series fixes the 3 identified mux drivers replacing the of_find_i2c_adapter_by_node() call by an of_get_i2c_adapter_by_node() call. Best regards, Hervé Herve Codina (3): i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node() i2c: muxes: i2c-mux-gpmux: Use of_get_i2c_adapter_by_node() drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +- drivers/i2c/muxes/i2c-mux-gpmux.c | 2 +- drivers/i2c/muxes/i2c-mux-pinctrl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)