Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3885646rwi; Sat, 22 Oct 2022 01:33:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM75TT3b7NPxRr21W1x1oHjpPGsHfpK0HYt/r4RI6QRpsNH4FELEAGVVxkzzCCzgTMq83NZx X-Received: by 2002:a63:f47:0:b0:46a:e00c:24c7 with SMTP id 7-20020a630f47000000b0046ae00c24c7mr19991303pgp.239.1666427581621; Sat, 22 Oct 2022 01:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427581; cv=none; d=google.com; s=arc-20160816; b=x9d9x62tQ0ate+DD3VblFrOKpw6AF4hnF4/sImVa92bwwuRf/zJ2UztVevN2HbQUSY Ehf/xRdAuV4zkSUkWn1A14CgtexK3AnHEtI2I+iQPh9P9NgkSSVcNxnQ9B6KKifknlaT PyME2h3aK+S2YIElaRqus9yGtiE9Nc+LpEtM+ukcP6ZC4eH+mqvkVQ+nOxOp0/sH7pZX RGMIyBMT2y17ZXMiX5SWC6Iqf3mBzSy7DHIX6skd4IwKVPn+76qM3DvbpYupkVc9JCFd t10vAhM7ThupqfmpjbT/XjvS/6LvyJoni7RGxHFY+bJuvOm0GMDVUrTpSPHBe1GU3Aik oCZw== 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=rhXD+g75m/68woPSUp34I8eVax0JZdfTvkjJkjSYwkY=; b=Ad5NQo1QDtxwD/ng8lvK2/vmHpJ5dBGeKup45YRSSlkypB/mKWrAY6UZLZGRBRIfrR 2ZfI9yMB/ofQNyWraMf9OLonMafQrXcOL2OI/iAQ8qW+IIwa6lSp0qAuQLyb5O4gAMee Gk86CJxaTwShiucJ7PRPW8dWita0RNO7zxfKqAulMtiwgeLAjglLw35MyQj3SLt4a8JE 9vYpCLeVPoQV4zh5jGaxZ3n0cyd3fzTivjMvdBuBGsdpK7LNru+TLkoKcIUxMZH7MVMz sBtbVtgi1bE7p63p9/fMcLFS5IzGsjUSVsAzH5mHzcpxkNV020u4cQBvS5GCwua3R6tz 8E5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bKGdVYKy; 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 e129-20020a636987000000b004597ddac1fasi26671689pgc.533.2022.10.22.01.32.50; Sat, 22 Oct 2022 01:33:01 -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=bKGdVYKy; 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 S232261AbiJVH6h (ORCPT + 99 others); Sat, 22 Oct 2022 03:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbiJVHyG (ORCPT ); Sat, 22 Oct 2022 03:54:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819A059EAA; Sat, 22 Oct 2022 00:47:22 -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 A558F60B1B; Sat, 22 Oct 2022 07:47:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B93A4C43470; Sat, 22 Oct 2022 07:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424830; bh=KNf54MzYOzZQ7PIZ9pF8uzpHZeVH6NK8nEr5MpJ/Xzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bKGdVYKysi7jdCE8zbZjoZbRPXYN2+/hHKhwSYMpPYfdML60nGKJTs08uHO0Xa4qE rfaNpefxPOWPUBwbAO12FU9/oaaucMqYQXVj9UsrO2jRjdpF6WZbbEi0+Fz+8HhK73 H0cijDpXQu4Cm3vP+nSlEFZ2crOtGgnMb84Rk9DY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , M Chetan Kumar , "David S. Miller" , Sasha Levin Subject: [PATCH 5.19 291/717] net: wwan: iosm: Call mutex_init before locking it Date: Sat, 22 Oct 2022 09:22:50 +0200 Message-Id: <20221022072504.847688169@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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 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: Maxim Mikityanskiy [ Upstream commit ba0fbdb95da5ddd8db457ce6ba09d16dd979a294 ] wwan_register_ops calls wwan_create_default_link, which ends up in the ipc_wwan_newlink callback that locks ipc_wwan->if_mutex. However, this mutex is not yet initialized by that point. Fix it by moving mutex_init above the wwan_register_ops call. This also makes the order of operations in ipc_wwan_init symmetric to ipc_wwan_deinit. Fixes: 83068395bbfc ("net: iosm: create default link via WWAN core") Signed-off-by: Maxim Mikityanskiy Reviewed-by: M Chetan Kumar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/wwan/iosm/iosm_ipc_wwan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_wwan.c b/drivers/net/wwan/iosm/iosm_ipc_wwan.c index 27151148c782..4712f01a7e33 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_wwan.c +++ b/drivers/net/wwan/iosm/iosm_ipc_wwan.c @@ -323,15 +323,16 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev) ipc_wwan->dev = dev; ipc_wwan->ipc_imem = ipc_imem; + mutex_init(&ipc_wwan->if_mutex); + /* WWAN core will create a netdev for the default IP MUX channel */ if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops, ipc_wwan, IP_MUX_SESSION_DEFAULT)) { + mutex_destroy(&ipc_wwan->if_mutex); kfree(ipc_wwan); return NULL; } - mutex_init(&ipc_wwan->if_mutex); - return ipc_wwan; } -- 2.35.1