* [PATCH] iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock()
@ 2021-11-06 16:53 Christophe JAILLET
2021-11-08 2:18 ` Lu Baolu
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2021-11-06 16:53 UTC (permalink / raw)
To: dwmw2, baolu.lu, joro, will, kevin.tian
Cc: iommu, linux-kernel, kernel-janitors, Christophe JAILLET
If we return -EOPNOTSUPP, the rcu lock remains lock. This is spurious.
Go through the end of the function instead. This way, the missing
'rcu_read_unlock()' is called.
Fixes: 7afd7f6aa21a ("iommu/vt-d: Check FL and SL capability sanity in scalable mode")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative, review with care.
---
drivers/iommu/intel/cap_audit.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/intel/cap_audit.c b/drivers/iommu/intel/cap_audit.c
index b39d223926a4..71596fc62822 100644
--- a/drivers/iommu/intel/cap_audit.c
+++ b/drivers/iommu/intel/cap_audit.c
@@ -144,6 +144,7 @@ static int cap_audit_static(struct intel_iommu *iommu, enum cap_audit_type type)
{
struct dmar_drhd_unit *d;
struct intel_iommu *i;
+ int rc = 0;
rcu_read_lock();
if (list_empty(&dmar_drhd_units))
@@ -169,11 +170,11 @@ static int cap_audit_static(struct intel_iommu *iommu, enum cap_audit_type type)
*/
if (intel_cap_smts_sanity() &&
!intel_cap_flts_sanity() && !intel_cap_slts_sanity())
- return -EOPNOTSUPP;
+ rc = -EOPNOTSUPP;
out:
rcu_read_unlock();
- return 0;
+ return rc;
}
int intel_cap_audit(enum cap_audit_type type, struct intel_iommu *iommu)
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock()
2021-11-06 16:53 [PATCH] iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock() Christophe JAILLET
@ 2021-11-08 2:18 ` Lu Baolu
0 siblings, 0 replies; 2+ messages in thread
From: Lu Baolu @ 2021-11-08 2:18 UTC (permalink / raw)
To: Christophe JAILLET, dwmw2, joro, will, kevin.tian
Cc: baolu.lu, iommu, linux-kernel, kernel-janitors
On 11/7/21 12:53 AM, Christophe JAILLET wrote:
> If we return -EOPNOTSUPP, the rcu lock remains lock. This is spurious.
> Go through the end of the function instead. This way, the missing
> 'rcu_read_unlock()' is called.
>
> Fixes: 7afd7f6aa21a ("iommu/vt-d: Check FL and SL capability sanity in scalable mode")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is speculative, review with care.
> ---
> drivers/iommu/intel/cap_audit.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/intel/cap_audit.c b/drivers/iommu/intel/cap_audit.c
> index b39d223926a4..71596fc62822 100644
> --- a/drivers/iommu/intel/cap_audit.c
> +++ b/drivers/iommu/intel/cap_audit.c
> @@ -144,6 +144,7 @@ static int cap_audit_static(struct intel_iommu *iommu, enum cap_audit_type type)
> {
> struct dmar_drhd_unit *d;
> struct intel_iommu *i;
> + int rc = 0;
>
> rcu_read_lock();
> if (list_empty(&dmar_drhd_units))
> @@ -169,11 +170,11 @@ static int cap_audit_static(struct intel_iommu *iommu, enum cap_audit_type type)
> */
> if (intel_cap_smts_sanity() &&
> !intel_cap_flts_sanity() && !intel_cap_slts_sanity())
> - return -EOPNOTSUPP;
> + rc = -EOPNOTSUPP;
>
> out:
> rcu_read_unlock();
> - return 0;
> + return rc;
> }
>
> int intel_cap_audit(enum cap_audit_type type, struct intel_iommu *iommu)
>
Nice catch! Thank you!
I will queue this for v5.16.
Best regards,
baolu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-08 2:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06 16:53 [PATCH] iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock() Christophe JAILLET
2021-11-08 2:18 ` Lu Baolu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).