From patchwork Sat Oct 22 07:22:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7332 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1094746wrr; Sat, 22 Oct 2022 01:00:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sWGaTaZEczBNBtipyLkplctghKRqt9NtRyt0z9MNqNzcdK86UlebsCpROGQo11lf7QSMi X-Received: by 2002:a17:90b:1f87:b0:212:533:3184 with SMTP id so7-20020a17090b1f8700b0021205333184mr14709174pjb.3.1666425655281; Sat, 22 Oct 2022 01:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425655; cv=none; d=google.com; s=arc-20160816; b=EdcD+NYP/SBqfn2PTNiw8Qpr0ohAusKd6Hb0Lv8JVqTCAiXlFBWyndVl6Va6dTAm3C EGaZExJjDJhe5ouQR6iJJ1547uQ037l62yUhKgUN4+hGF+swBBJuHFUvjkObH0JOS/Rs Lf/W+qAUodSQoUO92TfOXUtECznZtOBfFPeLtV22F7bGHR+WTrysjnrEbdDi7GN+VvLo AjqayovAROyETFpG2ca5tgutffQ0RlP9gzEtH7RouYrGLAdwuDgg8DsPyP7uVpdoXyWp ftNEkzwXeXtbjZpd/FE00Mr5BMRVfRyKXrzAwqAM9Gp5pxAAyGMJKkeVGh7pTPLjzrx2 vloQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a056a001a1000b00557e99763d3si31037473pfv.93.2022.10.22.01.00.37; Sat, 22 Oct 2022 01:00: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=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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373947689550639?= X-GMAIL-MSGID: =?utf-8?q?1747373947689550639?= 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; }