Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp802964rwi; Wed, 19 Oct 2022 03:12:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Vbt7Z45UdL1DAa22UsI5sfj7qlXbCUx5OEyvjQOOWVs5ok44Mf2ZHu6K2PElc9bXQyACW X-Received: by 2002:a17:906:9b93:b0:78d:eb36:1ce7 with SMTP id dd19-20020a1709069b9300b0078deb361ce7mr6104996ejc.621.1666174359878; Wed, 19 Oct 2022 03:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174359; cv=none; d=google.com; s=arc-20160816; b=XH6iNQBmSFEypIWC/R3T96AFsZjD/Jvzw2s/1ApG0bTlaN3lPsvUTrpRHwOkkV60BD NErHtEpxPRa9nzPaW7EYV8N8kuB+0NfcnJtd56h4FnZbK2K70ObA4rWjpjYwsvTDiQxF GqPfOTCrmT5aEF2wOqQ6cYwaSApGCYjUIiOlDBRVICTMaP8KAUeG7WEETfnm3wwSjipX ooBI6/hG/Mi4fWbqme2KBt1M5JqGp6f6dbOJh2qwxOFLtdAAodsL0U0piAzFXLrSIdUc S2SXIfYpcfTUiLw+ijy4LqR8Mtamgr5NuHhUTqUNGZKq0gX4WUiOQWfscI4sKsB4RaH5 LHeQ== 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=1I5jGJzqHJQ+1F0HYLmMrIo0iSgqlrpbhUOenyXCpPThP9r5v8HMAMfWub/3sOyT96 OLL6zsk5iFkJFMHKD43uD9SpUGukf5msDbM+0g8MEvXt7rbPXVc3PY3FvAzA9t8AiTJW kmmetGHJ7UxPLIN2XOlkNgUkl7O61YIZqTkn9Bj+hig+blDNjPSIBpDTf9vOts4kqlI8 3mVN8To+TaPQdJ1/LS1UNOKjruguHYMZWzcBVMOEFjyeP8QoKZu2/g+aw9O13Ihbk3J/ q/eNDT3t7iysXFzmTjLLm0Wi4F5EdwolRVC1zZDtPuGbjCOGYDwnC2TKMVU99fY03mNW aI+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qBuk/t0Q"; 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 y11-20020a056402358b00b0045d22bc81a0si13911137edc.231.2022.10.19.03.12.13; Wed, 19 Oct 2022 03:12:39 -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="qBuk/t0Q"; 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 S232163AbiJSJFT (ORCPT + 99 others); Wed, 19 Oct 2022 05:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbiJSJDt (ORCPT ); Wed, 19 Oct 2022 05:03:49 -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 D55321658A; Wed, 19 Oct 2022 01:56:37 -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 E8B4861812; Wed, 19 Oct 2022 08:55:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06DC1C433D6; Wed, 19 Oct 2022 08:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169700; bh=KNf54MzYOzZQ7PIZ9pF8uzpHZeVH6NK8nEr5MpJ/Xzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBuk/t0Q1n4pINunZfKttzn1cIZ73BZaO9gkVUc4KsA4qt+qrFzDU7Wd5vQxnZlCN 1m7rThqbWm4ev+pirA7zYlYYQ657Z4h8W6zePbsdGTtEHL7oxD6bM31d1xwb2f9uJw WiJ0ewZRNqbPRipDR0WhPCqpVjuPyWMd3ofELgk4= 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 6.0 342/862] net: wwan: iosm: Call mutex_init before locking it Date: Wed, 19 Oct 2022 10:27:09 +0200 Message-Id: <20221019083305.170906285@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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