Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp655054iog; Thu, 30 Jun 2022 07:46:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sgsh/S5m2XJUmVZIamguXIjvM8eiFWZ42d6tzn9YruWIF+o67yhgMh+QbPDBmG0UdSUYR6 X-Received: by 2002:a17:906:74c7:b0:722:e657:4220 with SMTP id z7-20020a17090674c700b00722e6574220mr9164688ejl.589.1656600415620; Thu, 30 Jun 2022 07:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656600415; cv=none; d=google.com; s=arc-20160816; b=NHjTUiO3xbKzpNGn9hvSijp8PnYftIpPXo1Fe4K2/RVGF0RV1HLtNNRbEUxOGHfdo0 ic1jd6YxOTiUnLB2gJHi+dO8XpfWt+bM9he7EqEAYbDiGUaHbveiYYBVU10ptHAodt7P J4Ee4Q+w2z+6/7ewdK+he7Qyj/uv/Iik0e3QDb9bBeXbw5LhqasxNP02HQgvI/ZW2OBx 613Am/lWToeZGEuzfH7IpJpk6HWYL0PDckz49s+/7TW/T5BdWS3BRJB1BR7+WzxUqytW Te7wo4RK97SxKrlHxBD8ePLrHvojC8ebNaSm+V4V7NZ4qK0A2T9R/Mj7h17s/OE7ZDkS LKAg== 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=/dFlJBxh3w1TUlX+kbQ6zJ25dJ4TSN3/EcvubnNFN8c=; b=xX+GN1vevd4eL/UCIhvH49MHzbNP45Qjz7XDC2OT3S/CKbwt/XL9XuK/GI4Qn1+ORG kAkgQhZmsJ0LK9B+P23Wn1NRJJIIrOFbOnqUlDJz0xYhxz3xlwZCJZyDI/QJU0ItlIbb gsnvM2A2EmNwcMGj9mT+miP4QzpuCkaniHr6Mku4ZBs6kFfcuIQTvpLdC7Dj/erQqB5Q p8AnDa5s48ndMNx9cOtFQwK1wQdifReBKO+gTEQ+W+bF5R3I4nP72171ZOfwNrieHEEF HfSY1AqWRoU+XGIpx0kY9W2ixXM4KG96rd4Zzl7oe84BNcOVWI78hgFEU/CFwahZy5rO hGLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ph+Iju+S; 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 h12-20020a170906260c00b0071c9ef2243asi3678350ejc.300.2022.06.30.07.46.28; Thu, 30 Jun 2022 07:46:55 -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=ph+Iju+S; 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 S235924AbiF3N7s (ORCPT + 99 others); Thu, 30 Jun 2022 09:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236552AbiF3N7J (ORCPT ); Thu, 30 Jun 2022 09:59:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C28C5C9CF; Thu, 30 Jun 2022 06:51:56 -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 D7687B82AD8; Thu, 30 Jun 2022 13:51:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45167C34115; Thu, 30 Jun 2022 13:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597091; bh=m+oZP3M4O1sZq5LvxLAL/YIm1EYOLHelNECdJS3rDQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ph+Iju+S/zD2vjtB7BE9MlLozfVwdDoORdfxxD4k+T6+OY+XeNzbURlqr9IaKizds xXcBmEt3WrJFxsPQd5mhkKUyiwETyEvDLC5CRnSBDQvWCwe0LkSOePpeAF0H8WMWQx ud8bedCW5quayj9jeHjjeGBzJdp42dzdixfW20sY= 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 4.19 25/49] iio:accel:bma180: rearrange iio trigger get and register Date: Thu, 30 Jun 2022 15:46:38 +0200 Message-Id: <20220630133234.640593622@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133233.910803744@linuxfoundation.org> References: <20220630133233.910803744@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 @@ -780,11 +780,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,