From patchwork Fri Oct 20 15:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 737206 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 E429ACDB474 for ; Fri, 20 Oct 2023 15:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377701AbjJTPa0 (ORCPT ); Fri, 20 Oct 2023 11:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377601AbjJTPa0 (ORCPT ); Fri, 20 Oct 2023 11:30:26 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8168D1A8; Fri, 20 Oct 2023 08:30:23 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 98EF4C000A; Fri, 20 Oct 2023 15:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697815821; 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=UnpnmeYe94FI9Jfaf1RckC7fZwJT75cGxhssDXRtfLA=; b=a6if/b3SxaI+6gCiPw/KJlnsg/xbge9hbOApvWT9BcBUmIPuNcGXH4DVGZmJtFBBofYzD4 Sc8ahz78YsknF/xDUjPRcktF3h4jDhnneh86GA7DcoTHq44B7yu+92+EBMVFjKS+hQDPL2 a/gKqbAcwAojaTnznhpm2O6POVI2OoXow+3FFr65mMWTpKg4Y1f4zMeq64dT1RSKLp95u3 cDx0gUMG/qk5lY0IHks90EsEUYgu7rPdZfmMhQ2aAUFs8KYHVKLaxt83Qv9+q72CMexeIA QQf1HHc5tyaFfqDYQJ7AjooUAmOVAl4sKJprFDrgaxxIlBPjpCSvY15RXcjpGg== From: Herve Codina To: Wolfram Sang , Peter Rosin , Stephen Warren , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v3 0/3] Fix i2c mux module refcount issues Date: Fri, 20 Oct 2023 17:30:10 +0200 Message-ID: <20231020153017.759926-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. Compare to the previous iteration https://lore.kernel.org/linux-kernel/20231019101017.425284-1-herve.codina@bootlin.com/ This v3 series: - Fixes a wrong char in a commit log message - Add 'Cc: stable@vger.kernel.org' - Add Reviewed-by tags Best regards, Hervé Changes v2 -> v3 - Patch 2 Replace a wrong char by a char in commit message - All patches Add 'Cc: stable@vger.kernel.org' Add 'Reviewed-by: Jonathan Cameron ' Changes v1 -> v2: - All patches Fix commit log Add relevant Fixes tag Add 'Acked-by: Peter Rosin ' 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(-)