From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 8146B418A5D for ; Wed, 12 Aug 2026 09:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786528167; cv=none; b=tjmwc96IB9AMbK0ROmAsXux9Z0VWO2/SQDN6uJeleUlwJooEZY4weGYcp11OP2jwBWfz9HDqvg7iDfUMtwy27AZKA+oFPARHPDrcyMvuRFZWtPBGEytU1iOKqGcziSiSntVfT5tDiksw9IV3dpoHAamdK7h6ZEmmkR2B1+ke2G0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786528167; c=relaxed/simple; bh=7lyXdQdjtI5/WAS+cJSExnEQhF25v7gRqCB3t62wdVM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LBDeGMLKKLhvd4g0UFBK3eVMZFb8sNNGA7BW629tmrR1O4+fHUp1k3pMArbUSRpdFP/GqF1FHWekIURcuPrcdicVfQsMsVK2BVCkJ/6R3ZZkXzNYIt79Sz1WO1H90b4uLTnf9Cv5k33wngqPMwJH/lh/enygDwshflH/lRJ+Js8= 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=z6+xNepN; arc=none smtp.client-ip=209.85.221.49 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="z6+xNepN" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-47f93b2fe4cso403751f8f.0 for ; Wed, 12 Aug 2026 02:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786528164; x=1787132964; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KNnL3c87mu/DIX31ZmKg4EMDsyOIpMA1GsTwk82rq7I=; b=z6+xNepNRYQYHQSCju6GTKpjMd8/AgvGXLhk5rV25EpY23ozDHfB6rG9+3jXhfeoB0 ZbSV57zvukYogwLdRf/cSGU89QOBBvZ0R4NcXizOjNxcwfsncotXLWRTnuJPP8J5djgQ r3YXd5FMzXon3pELUJP6OnVcOdpfjuQlfCSqhFQPQ37WLfyYV/6M9SosE/7fgKhvnh+g 5tgQ2ByR7536Db0bkTvhNEnCKZo5xwKb3Zieq/iuteyKJFQSpFPQlAU4ucdHNiMrmnuh OdNyPPqfOB3zHOQjyaxYfJmqVxJOLFDuSLB69ysm/SQmnpl9IdUrLOfyKO058SJYR2G1 PjBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786528164; x=1787132964; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to: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=KNnL3c87mu/DIX31ZmKg4EMDsyOIpMA1GsTwk82rq7I=; b=MIE/OKxaJOaHFWnC7hClbNBM9cL2SG45ULjg8yF1xHcDh4kHgf6xtaUSJFpCiUz9b2 UuAs11v5cipqUnZVqmyBzW+yUuOUU+OJcoA7RGxlUqYJqGZ/9ln46O+Gfvwb2ZBZ/bot 7O8yHPrddJ8BLR4fIXbsR57SJiVdxnibcCFa7IocqtOF0rou1qtYA8N3Qem8CwyijovM FOlWDhFRmDLtODKrqkFaPOxR2YfURn1fjT0TiyuDyCzYzQESMYTXHcyvVVMUTpYwCRK3 xyVmLQJ69t/ChjmReuT0e10+ItTkfGtUN8hRAdgvWA2fLCTexzal4c0Tz4V6UILzl/cu ihew== X-Forwarded-Encrypted: i=1; AHgh+Rp3/HK8R06QIqYpud8c0I+xtPbYioxJtyws9pml73fBnlBlQSPLcXM/nTXkoBIMVXoJBxTXD+tg8/xStQE=@vger.kernel.org X-Gm-Message-State: AOJu0YzbBwvB+TXaqQ4ihYgyDX2Hpox0WyabffaOc21oKN69v/eIuJva ooFsSzm6PkpW7uNjVGF9YZsy9DM6kdMEWFlihxmJOCTCTLohocY5YaXJwnXACYHMU1c= X-Gm-Gg: AR+sD11OclTxAEDLWYSiRFDtu8ZwY98z9aVjPAiXtpy6ysNDVmFRkrdXrN7FnMHYOmF Fd8u62blPPoRznhV8lVQyaSe78SBN3gDoyQREi7375VXTutvCqK88Iv3sR+ekftt2RdpZufOuVf lMkvsr7IS83drXvPURoFLPQ/+V4m8+WrsCtSp5sxTgrtYE6zAE8K9lzmlNkjqvJKR5GjmFz8Z7o h3TjkaXKHg7gwVKO7+hkLO5R4a2PwVnKHPeGTxGL2zCpei/24wuehLAz9w/Q2Vk1Wv7Pv3laCiV fhJ2yDdXgeHJjM6e99xZBOjWBWX58N33uDJoYYbmoW2CRcgr03lG36aXhMVKHLo4qVwZceqT5ss LDYK48uXYcggiMDW4Vs6o5Qn+itaFnM1N8uh0UC3viPKOvYY2lilqNtbUvW5PwZzcVU4IQ62ciY RJWmnHbMwVZXUNDw3QncgUK5UjpoY1DwiUFerEgs/GMsWQdczMIiOgCRNk23E8uAkS6aHORiOHU A01z6Ex X-Received: by 2002:a05:6000:41c2:b0:47f:aead:f81b with SMTP id ffacd0b85a97d-48152c75b41mr4968917f8f.21.1786528163621; Wed, 12 Aug 2026 02:49:23 -0700 (PDT) Received: from [192.168.0.252] ([79.115.63.18]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48150d5cba0sm5984868f8f.25.2026.08.12.02.49.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2026 02:49:23 -0700 (PDT) Message-ID: <5a4670bb-e24c-4adb-889a-01f54f04d32c@linaro.org> Date: Wed, 12 Aug 2026 12:49:20 +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 To: Runyu Xiao 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> Content-Language: en-US From: Tudor Ambarus In-Reply-To: <20260811083111.403453-1-runyu.xiao@seu.edu.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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") > Cc: stable@vger.kernel.org > Signed-off-by: Runyu Xiao Reviewed-by: Tudor Ambarus > --- > 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); > > if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) > return false;