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: 15593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp216828vqb; Thu, 19 Oct 2023 00:36:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3agL7ABFXHXThliT+3M3nuGYFy741dEJ1oCIxEUA13hLGm5On16ZKikJzBkbDELLUz+h6 X-Received: by 2002:a17:902:f9cb:b0:1c0:9b7c:f82a with SMTP id kz11-20020a170902f9cb00b001c09b7cf82amr1496048plb.53.1697700976614; Thu, 19 Oct 2023 00:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697700976; cv=none; d=google.com; s=arc-20160816; b=VB1zj6QeGgnQc7pfmVbpNnQgLUYjBxRdNYh2SJSWbg2IG6fOk8PGLgN7PAv9jc1/c1 ZDZdpVviYTshb64rDZzdYo+EisAXtZG0MoBjHuiF/2qFr5erN8dXkAOXBe3tgh2lrMYz tZSSIEOPMUHJR1PHhPqlvwFmJDywLonH37FnHfieqgP/nKl0jrDZ7UBKF6MSZS8fRyOG zBtwgn4QawNgAVDaF1VlP1x5aIeKsgq6W+rFUTB/IWqF+FKsIioNs4kManElDBvuf/o1 z2kTZkhUkoQPfLj0FvwOpXuPXmZFcKAYz2JWYQ4pIYAGu5Q5uNXrjOS41k43V5UuxOy/ R+Fg== 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:dkim-signature; bh=HucUa7dgW0DX1NhXf/pL0MQyRjRhnDgkYcJwUZwxjWk=; fh=vOhmkbio3vldgRDpkNvRPbxSZ54ZZOuVH6tekc4/rDo=; b=Mg/Sexrilpmdqq6NsGWB5pH4lxOkM9v6sy+QqxmUHJOuivyav8Yo6KYbwYe5WmxwIV 2AYOufnOFaaRDYpwRWmSzfvdx6YTHhJLgpLySLrNU/c8IQ7C+Ojnuvy+1F8CWI14NbtZ ZD5vbPFsSh834wHbJHjs/4/iIWGfW90I3fzPEHfCcuKJ8tBQTABoyqy5CdkorWQNhV+5 sdmqDiR3FdZeMYgUL8509mB3DCaveTcuVKPs+MMQh6+1jC4XRLnqHnVV+BPBN5faqz0S BykbEpwUcXqAjiKPlBfta8h2cjBqNULbSPxtL7QvP8m5bTt2pfl+93cuYiPw/bAyO94k RjlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jrY5dLO4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id x9-20020a170902820900b001b5589848absi1532376pln.234.2023.10.19.00.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jrY5dLO4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C6F7780D1EEF; Thu, 19 Oct 2023 00:36:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232927AbjJSHfq (ORCPT + 24 others); Thu, 19 Oct 2023 03:35:46 -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 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 00:36:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780168499148974996 X-GMAIL-MSGID: 1780168499148974996 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(-)