Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2903254iog; Mon, 27 Jun 2022 05:26:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tUKP/mtd6Gz+14fCGNHyVw2U+lMTJLuEIZ1seI8mgVPAyoVsoA1PKPao8KvSPcw5Gx1NsK X-Received: by 2002:a17:903:2311:b0:16a:6b9c:2b4d with SMTP id d17-20020a170903231100b0016a6b9c2b4dmr14537399plh.100.1656332806238; Mon, 27 Jun 2022 05:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332806; cv=none; d=google.com; s=arc-20160816; b=uUVmBPmB4IPhg4SjDybW9HCiDVxR7uN4mjQUOldKNp+iZvWrW3EbKPchUoesfPH1dL 34shiXgl9nG6wTYfoYc7JgU6pDEte+HCe5iPO3STY0kmUY7LaqoHqgOIHTx28QBvGdks iWmtBMbJa2fn6fpHOUQkVR6KLuUAIRXAgx+2A4Lq1DfFS7IMf3kJfDQ7QOdQgS4+JX5j V4CgKVv+oVEVb2ACk5TE1ZpMvZB+JoD7kcJ3KLXMVUeR2oH/U2eAcfokwXf70x6O0c9N 01Odj55NZ/vGa8yLX2E73DN56AiVuolNiSYAybvaYSKfli6tkdtRjKC+K4WhdrXHyOab d6ow== 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=aZiW1td6JA8KjS5JG+Eg65rN6H9NxB+mOIMe9HRCvwg=; b=zPHtvFK+87paeFpY7gQp47+D1XZVxX9wbKbzcOrWH4+jF9S3Sbfd61cA4Y9uq2Febl 7AOqRZd/DdeXImzdQFWuCJzuwv91zBSxxsppK7ZkNeMLc6q4MMfhn1eeXFGacBZrigTJ s2udvwBckYTdBWKBMNWuNamdHzslkAGqZulZsadf1g4moHYfnG7iN+JoeBtMKtd1ADQV U1rD/hCNBvqG7rol8GiTXST8uE0ua42ysCnq8oHv7xH0BBFVIlhIpJLPFKoHwxBS7Wd/ zMOnzFpQGkadypumeNuiKmBLlcsCEEyCcEaOBj7HLdnsvGtNwKTCwA7qDUSnIaqUbbrD BAEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YkPV5QKN; 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 l70-20020a638849000000b003fd260239b6si13696146pgd.584.2022.06.27.05.26.34; Mon, 27 Jun 2022 05:26:46 -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=YkPV5QKN; 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 S235245AbiF0L13 (ORCPT + 99 others); Mon, 27 Jun 2022 07:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235085AbiF0L0f (ORCPT ); Mon, 27 Jun 2022 07:26:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3890C658B; Mon, 27 Jun 2022 04:26:16 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BE9616149A; Mon, 27 Jun 2022 11:26:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4685C3411D; Mon, 27 Jun 2022 11:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329175; bh=rKBuajnzp1OaffylZWmkNesYTVoaItWgcdxM1fDoUWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkPV5QKNkM5DhUEi7bL58Xi5uGgs38bfe+1jCWv9BEngRXIEsuWICf4KHz8cKRuhq DY2g2KPsTCpCcexM6AzN9hXfl6U1CODTWbMjm+YQszKxmgcif9YVuWAmFekMcVoEJF IOxSSuWWTONK2cjnExCFZu6eZGSDCS2Vu5yhlyp8= 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.10 074/102] iio:accel:bma180: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:25 +0200 Message-Id: <20220627111935.665116782@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@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 @@ -1068,11 +1068,12 @@ static int bma180_probe(struct i2c_clien data->trig->dev.parent = 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,