Skip to contentSkip to conversation

memstick: fix a potential NULL pointer dereference

PATCH In review Kangjie Lu 2 participants 3 messages Mar 9, 2019 – Mar 23, 2019 Sony memorystick

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 memstick: fix a potential NULL pointer dereference

In case alloc_ordered_workqueue fails, the fix returns ENOMEM to avoid potential NULL pointer dereference.

---
 drivers/memstick/core/ms_block.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/memstick/core/ms_block.c +5 -0
index 82daccc9ea62..8e00de414567 100644
@@ -2149,6 +2149,11 @@ static int msb_init_disk(struct memstick_dev *card)
 
 	msb->usage_count = 1;
 	msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
+	if (!msb->io_queue) {
+		rc = -ENOMEM;
+		goto out_put_disk;
+	}
+
 	INIT_WORK(&msb->io_work, msb_io_work);
 	sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
 
Signature · 1 line
2.17.1
author
#1 lore raw

Hi Maxim,

Can you review this patch?

Thanks,

Quoted 29 lines · Kangjie Lu

In case alloc_ordered_workqueue fails, the fix returns ENOMEM to avoid potential NULL pointer dereference.

---
drivers/memstick/core/ms_block.c | 5 +++++

1 file changed, 5 insertions(+)
drivers/memstick/core/ms_block.c +5 -0
index 82daccc9ea62..8e00de414567 100644
@@ -2149,6 +2149,11 @@ static int msb_init_disk(struct memstick_dev *card)
 
 	msb->usage_count = 1;
 	msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
+	if (!msb->io_queue) {
+		rc = -ENOMEM;
+		goto out_put_disk;
+	}
+
 	INIT_WORK(&msb->io_work, msb_io_work);
 	sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by
#2 lore raw
Quoted 33 lines · Kangjie Lu

Hi Maxim,

Can you review this patch?

Thanks,

Quoted 26 lines · Kangjie Lu

In case alloc_ordered_workqueue fails, the fix returns ENOMEM to avoid potential NULL pointer dereference.

---
drivers/memstick/core/ms_block.c | 5 +++++

1 file changed, 5 insertions(+)
drivers/memstick/core/ms_block.c +5 -0
index 82daccc9ea62..8e00de414567 100644
@@ -2149,6 +2149,11 @@ static int msb_init_disk(struct memstick_dev *card)
 
      msb->usage_count = 1;
      msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
+     if (!msb->io_queue) {
+             rc = -ENOMEM;
+             goto out_put_disk;
+     }
+
      INIT_WORK(&msb->io_work, msb_io_work);
      sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
 
Quoted 3 lines
Quoted 3 lines

--
2.17.1

Looks OK to me!

Best regards,
Maxim Levitsky