Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2923963iog; Mon, 27 Jun 2022 05:53:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tGGrslmrtTAQztAKRD/RfvCCU2r38HrmxKkm0Opm9vouROQw4HGtXtyZfQA4IN+nQ/ziDO X-Received: by 2002:a17:90b:4c49:b0:1ec:e8a2:b5f0 with SMTP id np9-20020a17090b4c4900b001ece8a2b5f0mr20340760pjb.21.1656334393414; Mon, 27 Jun 2022 05:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656334393; cv=none; d=google.com; s=arc-20160816; b=qL9sXtGREKK1wEUsgmTdoLEIGn7pWqrPtxfqflBDh8NmKNGap2fLkdt4sKJdfVQcea LVHltcXIpaXlQramR6sV/zjJn8F1UF/F4byY0UH5A2MEsk2FICgN1sQL7hYWKnwOUGXC qb23js5nAOG/XgciTMNJqzcVVNCW/gl6zCWZGR/QTvjcYkUChOoNU2Jj/fRNhgfCleNy HQSmGCy1xG4ewX3rZ32VMVGFDyjOpPmtJ6/g2dqFgUViCE1rLj1tV0otBKwWUW4V2wg0 vYSx9da+Skxl4kscVKeGFUcZAYhIJSX3RxqiBbZDWbqeO1WkzJIlhfmy1jVaqEuczMY6 lbaA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sxz1N1L5YLNgGl+QzALtO9FSxd5r2sQxQZ6oT0soNTw=; b=AoTkaP7nRnV68/oglRz2NztWrLddHFch8qAjJ3YC8kSIJOkHOKFnj2ItLZaIf5Syqe hJpejuR18kek11kePjVsQ5eNm+ApIr+EEQ3Jz83uIoPruFZyM+pWQ6sAZ3Ft/37/ns6U Qc2Ngc6Uy4/oVN2XrsXPk9I70JBtndigqWznY0+6s2ANIlvNZzyNpiJF72rSWrD7yVNZ bbvQBd1zqA9wGEbyggrXYSE/l63OY3yiJ8bopySvkfwfT0naS7wzFKB41qvxhVR4NAVi JVdX+7mAGGTQnKx2msYQP1jPzho3q6rPI6A+mUPDXao1YymIXP6izXhe91pIo/4UdBx/ oiRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y5kLny5X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe11-20020a17090b4f8b00b001df8f8d3daasi11036557pjb.162.2022.06.27.05.53.01; Mon, 27 Jun 2022 05:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y5kLny5X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235734AbiF0LeK (ORCPT + 99 others); Mon, 27 Jun 2022 07:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235855AbiF0Lcu (ORCPT ); Mon, 27 Jun 2022 07:32:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B0DBC27; Mon, 27 Jun 2022 04:29:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 11E94B81120; Mon, 27 Jun 2022 11:29:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4817AC3411D; Mon, 27 Jun 2022 11:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329382; bh=CSba8t3KPko6bwOZeRrf8R9GFqgz31Oy3X9V/EUquhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y5kLny5XTR3bK+XDBa7zryEsERgzDhrtsD4M8ZPSa0T7f3a/Ohhb7qqH8QAVX+zY9 PGogmvs1n/mLG54Ftp/n/RULe2MqUdMnEU2gaNbwr7FkCm4D1M3MPPoUzZbXMz96/i 7VcdHW5rmmrVaGDV0oUwl9GhqX6S9Wic9JDsfZMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Rokosov , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.4 39/60] iio:accel:bma180: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:50 +0200 Message-Id: <20220627111928.840058568@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111927.641837068@linuxfoundation.org> References: <20220627111927.641837068@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Rokosov commit e5f3205b04d7f95a2ef43bce4b454a7f264d6923 upstream. IIO trigger interface function iio_trigger_get() should be called after iio_trigger_register() (or its devm analogue) strictly, because of iio_trigger_get() acquires module refcnt based on the trigger->owner pointer, which is initialized inside iio_trigger_register() to THIS_MODULE. If this call order is wrong, the next iio_trigger_put() (from sysfs callback or "delete module" path) will dereference "default" module refcnt, which is incorrect behaviour. Fixes: 0668a4e4d297 ("iio: accel: bma180: Fix indio_dev->trig assignment") Signed-off-by: Dmitry Rokosov Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220524181150.9240-2-ddrokosov@sberdevices.ru Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/bma180.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -793,11 +793,12 @@ static int bma180_probe(struct i2c_clien data->trig->dev.parent = &client->dev; data->trig->ops = &bma180_trigger_ops; iio_trigger_set_drvdata(data->trig, indio_dev); - indio_dev->trig = iio_trigger_get(data->trig); ret = iio_trigger_register(data->trig); if (ret) goto err_trigger_free; + + indio_dev->trig = iio_trigger_get(data->trig); } ret = iio_triggered_buffer_setup(indio_dev, NULL,