Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3329647pxb; Fri, 4 Feb 2022 06:25:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuyN6uMZ1KEyR+9bKiUlZQdpKAZgZf60j7OES8ReTDdO1f4qLuDPpjhAOgaJ+/Bk8n9viH X-Received: by 2002:a65:5cc1:: with SMTP id b1mr2527060pgt.341.1643984718817; Fri, 04 Feb 2022 06:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643984718; cv=none; d=google.com; s=arc-20160816; b=yRZhDskf3T0iJUn15A1Q44pLq0sNyPzHqNd8kBXbuv9mkMqe40dwKiWwm4xrmbK+uJ NI3GF2Lo3PcRD6z39oGzASV9JG5iNXyFWSe4jHlbDIS5Wn9coXcKuUmTaMoj+uR3N80m h7swG54GIMy4Srg9GsnyotliKPxGNxXWuZMSXahc7Kmr5USVXBlsisBwZLMeHdOiBue9 gDr+uOZ1dEWy6mMBRaJXIQh/GqwEQD5s0QjfhQ39a5Flw/BzYh1lCMnSMYpP0jLt6LpJ ApNXUDlSa9ZX3ia28aX14DyQyFPKVPunenNZChrsKTRBok2dlvXft4EOiz0htk8cR9JM rxbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :mime-version:user-agent:date:message-id:cc:to:subject:from :dkim-signature; bh=30OxmrfKBbCG4hj/X3lsJFFvPMa8rJcIl2RH+GTl1+c=; b=0wTft8Bpt2vW4PtfULX2vYLmReJUWvCAolhxPynDx4Ym+i0T3LeP537MXN2zJlxqA7 UnZLNAl82+OZXuHfaR/IHFuJFMUM9oVZDREcMErBQ25HYcD13kwQBHdg4GvRwV1SMOgS BfhUA+M0CGedaRjMoEPt3aIGyAEXcga6yP+jsH1XJ7cPkkFNJbvtoZYgHh73U0SFmuKw esakl/K/6vhjY3jWsCn8rcrCBOu+2DZeotIG/4mBcCyt75nLUbZpnubkaLpGh6ZRtUEa 2YVxVgodzNcZjCto3DvZwH9yEYCa7hRORpbu5KrpmNcOkbU5vnxh+IJ3iUS1F9V8gQYq 2c2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mhDV0XtJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s142si1944596pgs.337.2022.02.04.06.25.05; Fri, 04 Feb 2022 06:25:18 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=mhDV0XtJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234550AbiBAHJp (ORCPT + 99 others); Tue, 1 Feb 2022 02:09:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233870AbiBAHJo (ORCPT ); Tue, 1 Feb 2022 02:09:44 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554A8C061714 for ; Mon, 31 Jan 2022 23:09:44 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id 132so3508226pga.5 for ; Mon, 31 Jan 2022 23:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=30OxmrfKBbCG4hj/X3lsJFFvPMa8rJcIl2RH+GTl1+c=; b=mhDV0XtJlte0Om1SvFzaHSKspJpOm4zs+iaK7pwkTbq02CRjXk7keFp0VG1dgt3NAQ HhZlEK8n/5JsdmEiiQgaYAyhBJ8QJOSOQknTuBXjZ5oj0+MtTPh8fVsqxVLFjWWxuW/v wQ59egONKIocS0nvyFlCnlLGT1yIaPO14HhFbVcCyQVsX0TqGvo+HUCSJcXUOnI2pC10 WNBa763RKmq7xot14B/U2BzflA796QfH98wCFvmBVEmtiQ7VnCtqIvoblsjaW236AAgf shU7DLKubnotSnFp/70OkQBgfj8DGsLOwm5y2os0E/SHhZpxFpX6lMq6hMmvbIRKOdOD TMnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=30OxmrfKBbCG4hj/X3lsJFFvPMa8rJcIl2RH+GTl1+c=; b=N17oqmJdJTJ7trhr9Iy89kyJGNdS+GqTjw+sxYd8cZnL0/RywwDu2ZmpwFBW46Wlul aKJzWF03Q3wRXwxPy1aT4PbeW9Tt7bfC8muhlNAA+dM5QTdBy2QThe05UuOgZ/8eo6q2 RXYmBMidUHzYx/LB5OCw4aDEXqAOkDBEobOCjg6EcHvYDDYy8G06TiY/EspvCBsnyhS+ 63exZNg4xQVtUAMj/iFQtsd7/eAAln7do61YYqQJd4aQdsdETeSYQrYQCKDkwsEbg6lh 9YdrHe0DP/BhwImIGpPnZgT60S5zFxfXEzRryIn0+CAcRgSzGiBmnDBq9N7a4blsukP4 b/1Q== X-Gm-Message-State: AOAM53049Uj1htpNJp8wBjZEhxwVPxa05DeTUQOD0wzaB5yAwxovNq8h xUCaFklWyEBeZjTnyaVk/Zwz7VfyQA0= X-Received: by 2002:a63:f30e:: with SMTP id l14mr19357924pgh.410.1643699383259; Mon, 31 Jan 2022 23:09:43 -0800 (PST) Received: from [10.59.0.6] ([85.203.23.80]) by smtp.gmail.com with ESMTPSA id q19sm19964158pfn.159.2022.01.31.23.09.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Jan 2022 23:09:42 -0800 (PST) From: Jia-Ju Bai Subject: [BUG] staging: wfx: possible deadlock in wfx_conf_tx() and wfx_add_interface() To: jerome.pouiller@silabs.com, Greg KH Cc: linux-staging@lists.linux.dev, linux-kernel Message-ID: <6f489bf2-bac0-8030-7ea5-6f5c12daa568@gmail.com> Date: Tue, 1 Feb 2022 15:09:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, My static analysis tool reports a possible deadlock in the wfx driver in Linux 5.16: wfx_conf_tx()   mutex_lock(&wdev->conf_mutex); --> Line 225 (Lock A)   wfx_update_pm()     wait_for_completion_timeout(&wvif->set_pm_mode_complete, ...); --> Line 3019 (Wait X) wfx_add_interface()   mutex_lock(&wdev->conf_mutex); --> Line 737 (Lock A)   complete(&wvif->set_pm_mode_complete); --> Line 758 (Wake X) When wfx_conf_tx() is executed, "Wait X" is performed by holding "Lock A". If wfx_add_interface() is executed at this time, "Wake X" cannot be performed to wake up "Wait X" in wfx_conf_tx(), because "Lock A" has been already hold by wfx_conf_tx(), causing a possible deadlock. I find that "Wait X" is performed with a timeout, to relieve the possible deadlock; but I think this timeout can cause inefficient execution. I am not quite sure whether this possible problem is real and how to fix it if it is real. Any feedback would be appreciated, thanks :) Best wishes, Jia-Ju Bai