From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31EED43A819 for ; Tue, 11 Aug 2026 10:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786444944; cv=none; b=o9HTMKnkhQTYk1wMNOne3VagQx0dCUusTyyaDVIzyCsHvsR0rd7Z0EGTiyPkrx2RztcY4BoRqIR0Sex41EzlyDWSwJlB8/LltEvo57bztWKdMM8QgppcvqirRRyTeW4svxxN4luYra9c/BrTesUwdQc2APuAc3lI55xUndxgg44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786444944; c=relaxed/simple; bh=9DWwyp1KRArEjU+uq1Qkw7+RtV8sKm9Jirs8RjgfOuM=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=o2W88NnkoZ48VVrWyMMXDIqqKOaHTRbLo+zNd6vmBXyFGTHXe9t9PaF96inSG7e8/0wT2ZeVIpTxt21hi8zFIbj4AgkZ9ajkdXiq+ER3M5ATkb15eCI8KAwOySTArjhKzcFWLX1sz23eZz+H93Cyolag/aqY+gITOL+UVUfIsOs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JbYAdc17; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JbYAdc17" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so40679375e9.2 for ; Tue, 11 Aug 2026 03:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786444941; x=1787049741; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=FOccx3o7YzspIOPN4VOMh1mmGB1X25Vq6yEwYlGFjto=; b=JbYAdc1725Squ0YBQLUBaIlhUtifEtQYD3uRDi7rnwo6zGZg1hT4zJ4Fecc+T0C6tO kn4A+JgbMPNQ4I5hGD8j8b2WYLLulmom8B+u2biH3E4ntg8vCVXRQt1MKk30cUb/Z3SW YIl9OcpBnA6JNqekiW1dnI7gvBDxKvwi35Pp4V5g/T2EL2GYzWJv9QeRoCvibEuPIVjs gKAuOcUKUJOzThG4F4ls0gr5q8VcjCiuZEtXlJblkt1nfz1xt1LG4deghg94KcI24zSF o7DYqEenGeA8J3NBDLYzR4kKMyU/FXpa+yi6/VJevXhYqm6PPRvfZ8Mpz87WL90/d8KS 7JlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786444941; x=1787049741; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FOccx3o7YzspIOPN4VOMh1mmGB1X25Vq6yEwYlGFjto=; b=LnS74wcQGV/ec0Kvu7A1dyyOj/7ZMlHXIlOHwaDFyEr7AiqtB/Cwsvc8v/xPWm8iiD FnRV/JhF+V5uP2dAzMgJQ/Teeuuy2B2C6VoOElMF7W0BKxHbZocToKwsWgpiH7d7s7dc E5CgGC8cINBr57wGTVvqv14/Ufer4Dc0YCcatMfRrhoCTyMUtm/cInAur+R8LzOBdzi5 VJk1MuKLk/pvVyWZbeHceA32Ps6jX+LHfFhl6lm4kJ9m/DkBNJqh8DnLy69M2/aOA0eZ QcVyv2QAof54NW5cMiAI8nv14DEO2fwekVPH2wNdHxgg5dkICOYlftimnlcESLdjMtY9 IsnQ== X-Forwarded-Encrypted: i=1; AHgh+RoSX4QYO45/2BY/H8GqtjVKMcgNSz9JgySAB3ryCSldKgYbFchFaFXRBVm5/fLVGDXtGzi8rQp7dWiuZrQ=@vger.kernel.org X-Gm-Message-State: AOJu0YybhnMcJIZeqMEIy8XDvDFmBTi852RaqWtbYi8joEkmhv/c0Gdj Y5EV714Ke4sa4Y247gdhEvkAAp7aTBOKg6zIuf6UTEbSHNzE2SYUb71O7nhQ17vGND8= X-Gm-Gg: AR+sD13i4PKvPw/0g35gb0I0IfeJGaLgxgWnqO6SO/5Xi/zWu+FhL4LuikkZGA15r+x y9eLXHnCiFe3F5slkOBCVPiQlkGtcxSsVp8Gqmt9n4LOKa4HM5Nk009Vvmp7rNR/SS8zLwNn1T3 IMtfRJJWRUe2WXeO2IcmFzM48tTgAD3dSaaCxBFN19JwrwQ2CBUQNd4rimZGL9lk3sM6Dt/na7A IeTsbKp333czkyTxNheAQEi7Wr0ELkYnfMIYQn+K2doX7uW8zMvnYsVqt22SMmd2bIOD4050se3 JD7ebM8l4GsH+0HBBnu9MpiXD+AvgmeNpPIi9ruE89fftVWzYGQUfofhLEktB6jygqQ94NNbc7z McpQn2KZj57K3joPNDsdiR6h4k66erK4HECZEkIIBNAW367tvLm8/WolMUTZANKPvVSVWIBYYgp VwUEZNfWs6Rcq2/6m9jsMvqO9U7KP0vMDI4i0Z4708f77K205JD1bBgBjbs+MPVfwbGPQL1dA= X-Received: by 2002:a05:600c:4753:b0:498:943:ccc0 with SMTP id 5b1f17b1804b1-49978437740mr26481275e9.6.1786444940360; Tue, 11 Aug 2026 03:42:20 -0700 (PDT) Received: from [192.168.0.252] ([79.115.156.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49977e57785sm37389935e9.2.2026.08.11.03.42.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2026 03:42:19 -0700 (PDT) Message-ID: <56991b48-cbe9-45bf-a24c-d7aa771c55d2@linaro.org> Date: Tue, 11 Aug 2026 13:42:17 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mtd: spi-nor: use guard() in spi_nor_rww_start_exclusive From: Tudor Ambarus To: Runyu Xiao , Miquel Raynal Cc: Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jianhao.xu@seu.edu.cn References: <20260811041349.333176-1-runyu.xiao@seu.edu.cn> <20260811083111.403453-1-runyu.xiao@seu.edu.cn> <0ff8afdc-7a11-4a6c-9f62-6f8ba712c4ac@linaro.org> Content-Language: en-US In-Reply-To: <0ff8afdc-7a11-4a6c-9f62-6f8ba712c4ac@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, Runyu, Miquel, On 8/11/26 1:11 PM, Tudor Ambarus wrote: > > > On 8/11/26 11:31 AM, Runyu Xiao wrote: >> Commit 03e7bb864d9a ("mtd: spi-nor: use scope-based mutex cleanup >> helpers") converted the RWW start helpers to scoped mutex cleanup, but >> left spi_nor_rww_start_exclusive() using a plain mutex_lock(). >> >> spi_nor_rww_start_exclusive() is used as a wait_event_killable() >> condition. When it returns false on the busy path, the raw mutex_lock() >> leaves nor->lock held and blocks the operation that must clear the RWW >> state in spi_nor_rww_end_exclusive(). >> >> Use guard(mutex) here as well so this helper matches the other RWW >> start helpers and releases nor->lock on the false return path. >> >> Fixes: 03e7bb864d9a ("mtd: spi-nor: use scope-based mutex cleanup helpers") > > The fixes tag is wrong. The blamed commit did not change the functionality > of the code, while yours does. > > You shall instead blame the commit that failed to release the lock in the > first place. But then if you want to have this backported to stable kernels > you may want to add 03e7bb864d9a ("mtd: spi-nor: use scope-based mutex > cleanup helpers") as a prerequisite patch, as it includes . > Runyu, please also update the commit subject, the point of the patch is that it fixes a mutex leak, thus I suggest to reword it with something like "mtd: spi-nor: core: Fix mutex leak in spi_nor_rww_start_exclusive()" >> Cc: stable@vger.kernel.org >> Signed-off-by: Runyu Xiao >> --- >> Changes in v3: >> - Reframe the changelog around the scoped-helper conversion that missed >> spi_nor_rww_start_exclusive(). >> >> Changes in v2: >> - Replace the analysis-style explanation with a short maintainer-facing >> description of the busy-path lock hold. >> - Keep the fix focused on using guard(mutex) so the mutex is released on >> both paths. >> >> drivers/mtd/spi-nor/core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c >> index ccf4396cdcd0..8bc117b46e02 100644 >> --- a/drivers/mtd/spi-nor/core.c >> +++ b/drivers/mtd/spi-nor/core.c >> @@ -1310,7 +1310,7 @@ static bool spi_nor_rww_start_exclusive(struct spi_nor *nor) >> { >> struct spi_nor_rww *rww = &nor->rww; >> >> - mutex_lock(&nor->lock); >> + guard(mutex)(&nor->lock); >> Miquel, Have you seen sashiko's review at https://sashiko.dev/#/patchset/20260811083111.403453-1-runyu.xiao%40seu.edu.cn? Both concerns look valid to me. Do you think you can allocate time to fix them? Cheers, ta >> if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) >> return false; >