iommu/vt-d: Unlock on error paths
Subsystems (2)
PATCH 1/1 iommu/vt-d: Unlock on error paths
There were a couple places where we need to unlock before returning.
--- drivers/iommu/intel-iommu-debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/intel-iommu-debugfs.c +4 -2
@@ -289,11 +289,12 @@ static int dmar_translation_struct_show(struct seq_file *m, void *unused) sts =dmar_readl (iommu->reg +DMAR_GSTS_REG );if (!(sts &DMA_GSTS_TES )) {seq_puts (m,"DMA Remapping is not enabled\n" ); -return 0 ; + goto unlock; }root_tbl_walk (m, iommu);seq_putc (m,'\n' ); } +unlock:rcu_read_unlock ();return 0 ;
@@ -444,7 +445,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) sts =dmar_readl (iommu->reg +DMAR_GSTS_REG );if (!(sts &DMA_GSTS_IRES )) {seq_puts (m,"Interrupt Remapping is not enabled\n" ); -return 0 ; + goto unlock; }if (iommu->ir_table) {
@@ -475,6 +476,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) }seq_putc (m,'\n' ); } +unlock:rcu_read_unlock ();return 0 ;
Signature · 1 line
2.20.1
Quoted 37 lines · Dan Carpenter
There were a couple places where we need to unlock before returning.
Fixes 91391b919e19 ("iommu/vt-d: Populate debugfs if IOMMUs are detected")Signed-off-by Dan Carpenter <[email protected]>--- drivers/iommu/intel-iommu-debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/iommu/intel-iommu-debugfs.c +3
-2@@ -289,11 +289,12 @@ static int dmar_translation_struct_show(struct seq_file *m, void *unused) sts =dmar_readl (iommu->reg +DMAR_GSTS_REG );if (!(sts &DMA_GSTS_TES )) {seq_puts (m,"DMA Remapping is not enabled\n" ); -return 0 ; + goto unlock; }root_tbl_walk (m, iommu);seq_putc (m,'\n' ); } +unlock:rcu_read_unlock ();return 0 ;@@ -444,7 +445,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) sts =dmar_readl (iommu->reg +DMAR_GSTS_REG );if (!(sts &DMA_GSTS_IRES )) {seq_puts (m,"Interrupt Remapping is not enabled\n" ); -return 0 ; + goto unlock; }if (iommu->ir_table) {
drivers/iommu/intel-iommu-debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 482
Quoted 7 lines
drivers/iommu/intel-iommu-debugfs.c +1
-0@@ -475,6 +476,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) }seq_putc (m,'\n' ); } +unlock:rcu_read_unlock ();return 0 ;
Thanks a lot for the catch. I think it could be further cleanup. How about below changes?
index 8d24c4d85cc2..2583a6743dd0 100644
drivers/iommu/intel-iommu-debugfs.c +0 -0
@@ -288,8 +288,9 @@ static int dmar_translation_struct_show(struct
seq_file *m, void *unused)
for_each_active_iommu(iommu, drhd) {
sts = dmar_readl(iommu->reg + DMAR_GSTS_REG);
if (!(sts & DMA_GSTS_TES)) {
- seq_puts(m, "DMA Remapping is not enabled\n");
- return 0;
+ seq_printf(m, "DMA Remapping is not enabled on
%s\n",
+ iommu->name);
+ continue;
}
root_tbl_walk(m, iommu);
seq_putc(m, '\n');
@@ -431,7 +432,6 @@ static int ir_translation_struct_show(struct
seq_file *m, void *unused)
struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu;
u64 irta;- u32 sts;
rcu_read_lock();
for_each_active_iommu(iommu, drhd) {@@ -441,12 +441,6 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused)
seq_printf(m, "Remapped Interrupt supported on IOMMU:
%s\n",
iommu->name);
- sts = dmar_readl(iommu->reg + DMAR_GSTS_REG);
- if (!(sts & DMA_GSTS_IRES)) {
- seq_puts(m, "Interrupt Remapping is not enabled\n");
- return 0;
- }
-
if (iommu->ir_table) {
irta = virt_to_phys(iommu->ir_table->base);
seq_printf(m, " IR table address:%llx\n", irta);Best regards,
baolu
Quoted 37 lines · Lu Baolu
Quoted 36 lines · Dan Carpenter
There were a couple places where we need to unlock before returning.
Fixes 91391b919e19 ("iommu/vt-d: Populate debugfs if IOMMUs are detected")Signed-off-by Dan Carpenter <[email protected]>--- drivers/iommu/intel-iommu-debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/iommu/intel-iommu-debugfs.c +3
-2@@ -289,11 +289,12 @@ static int dmar_translation_struct_show(struct seq_file *m, void *unused) sts =dmar_readl (iommu->reg +DMAR_GSTS_REG );if (!(sts &DMA_GSTS_TES )) {seq_puts (m,"DMA Remapping is not enabled\n" ); -return 0 ; + goto unlock; }root_tbl_walk (m, iommu);seq_putc (m,'\n' ); } +unlock:rcu_read_unlock ();return 0 ;@@ -444,7 +445,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) sts =dmar_readl (iommu->reg +DMAR_GSTS_REG );if (!(sts &DMA_GSTS_IRES )) {seq_puts (m,"Interrupt Remapping is not enabled\n" ); -return 0 ; + goto unlock; }if (iommu->ir_table) {@@ -475,6 +476,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) }seq_putc (m,'\n' );
Quoted 8 lines
drivers/iommu/intel-iommu-debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 482
Quoted 5 lines
drivers/iommu/intel-iommu-debugfs.c +1
-0} +unlock:rcu_read_unlock ();return 0 ;Thanks a lot for the catch. I think it could be further cleanup. How about below changes?
Obviously that solves the issues with forgetting to drop the lock but I'm not qualified to comment on the rest. (And I can't really review it anyway because the patch was damaged in sending the email).
regards,
dan carepnter