Skip to contentSkip to conversation

platform/x86: dell_rbu: fix lock imbalance in img_update_realloc

PATCH In review Christoph Hellwig 3 participants 3 messages Feb 11, 2019 – Feb 15, 2019 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: dell_rbu: fix lock imbalance in img_update_realloc

We need to ensure rbu_data.lock is always held on return.

Fixes 289790a3ea94 ("platform/x86: dell_rbu: stop abusing the DMA API")
---
 drivers/platform/x86/dell_rbu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/dell_rbu.c +1 -1
index 8104ca0c44ca..031c68903583 100644
@@ -436,6 +436,7 @@ static int img_update_realloc(unsigned long size)
 	ordernum = get_order(size);
 	image_update_buffer =
 		(unsigned char *)__get_free_pages(GFP_DMA32, ordernum);
+	spin_lock(&rbu_data.lock);
 	if (!image_update_buffer) {
 		pr_debug("Not enough memory for image update:"
 			"size = %ld\n", size);
@@ -446,7 +447,6 @@ static int img_update_realloc(unsigned long size)
 	if (WARN_ON_ONCE(img_buf_phys_addr > BIOS_SCAN_LIMIT))
 		return -EINVAL; /* can't happen per definition */
 
-	spin_lock(&rbu_data.lock);
 	rbu_data.image_update_buffer = image_update_buffer;
 	rbu_data.image_update_buffer_size = size;
 	rbu_data.bios_image_size = rbu_data.image_update_buffer_size;
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Christoph Hellwig

We need to ensure rbu_data.lock is always held on return.

Fixes 289790a3ea94 ("platform/x86: dell_rbu: stop abusing the DMA API")
---
 drivers/platform/x86/dell_rbu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/dell_rbu.c +1 -0
index 8104ca0c44ca..031c68903583 100644
@@ -436,6 +436,7 @@ static int img_update_realloc(unsigned long size)
 	ordernum = get_order(size);
 	image_update_buffer =
 		(unsigned char *)__get_free_pages(GFP_DMA32, ordernum);
+	spin_lock(&rbu_data.lock);
 	if (!image_update_buffer) {
 		pr_debug("Not enough memory for image update:"
 			"size = %ld\n", size);

drivers/platform/x86/dell_rbu.c static int img_update_realloc(unsigned long size) · line 452

Quoted 7 lines
drivers/platform/x86/dell_rbu.c +0 -1
@@ -446,7 +447,6 @@ static int img_update_realloc(unsigned long size)
 	if (WARN_ON_ONCE(img_buf_phys_addr > BIOS_SCAN_LIMIT))
 		return -EINVAL; /* can't happen per definition */
 
-	spin_lock(&rbu_data.lock);
 	rbu_data.image_update_buffer = image_update_buffer;
 	rbu_data.image_update_buffer_size = size;
 	rbu_data.bios_image_size = rbu_data.image_update_buffer_size;
#2 lore raw
Quoted 6 lines · Stuart Hayes
Quoted 2 lines · Christoph Hellwig

We need to ensure rbu_data.lock is always held on return.

Pushed to my review and testing queue, thanks!

Quoted 30 lines
Quoted 21 lines
Fixes 289790a3ea94 ("platform/x86: dell_rbu: stop abusing the DMA API")
---
 drivers/platform/x86/dell_rbu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/dell_rbu.c +1 -0
index 8104ca0c44ca..031c68903583 100644
@@ -436,6 +436,7 @@ static int img_update_realloc(unsigned long size)
      ordernum = get_order(size);
      image_update_buffer =
              (unsigned char *)__get_free_pages(GFP_DMA32, ordernum);
+     spin_lock(&rbu_data.lock);
      if (!image_update_buffer) {
              pr_debug("Not enough memory for image update:"
                      "size = %ld\n", size);

drivers/platform/x86/dell_rbu.c static int img_update_realloc(unsigned long size) · line 452

Quoted 7 lines
drivers/platform/x86/dell_rbu.c +0 -1
@@ -446,7 +447,6 @@ static int img_update_realloc(unsigned long size)
      if (WARN_ON_ONCE(img_buf_phys_addr > BIOS_SCAN_LIMIT))
              return -EINVAL; /* can't happen per definition */
 
-     spin_lock(&rbu_data.lock);
      rbu_data.image_update_buffer = image_update_buffer;
      rbu_data.image_update_buffer_size = size;
      rbu_data.bios_image_size = rbu_data.image_update_buffer_size;
Signature · 2 lines
With Best Regards,
Andy Shevchenko