[PATCH] scsi: hpsa: add return value check for remap_pci_mem()

Haoxiang Li posted 1 patch 2 weeks ago
drivers/scsi/hpsa.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] scsi: hpsa: add return value check for remap_pci_mem()
Posted by Haoxiang Li 2 weeks ago
In hpsa_enter_performant_mode(), add return value check
for remap_pci_mem() to prevent potential null pointer
dereference.

Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/scsi/hpsa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3654b12c5d5a..f3118695f320 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -9323,6 +9323,8 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
 					cfg_offset + bft2_offset,
 					ARRAY_SIZE(bft2) *
 					sizeof(*h->ioaccel2_bft2_regs));
+		if (!h->ioaccel2_bft2_regs)
+			return -ENODEV;
 		for (i = 0; i < ARRAY_SIZE(bft2); i++)
 			writel(bft2[i], &h->ioaccel2_bft2_regs[i]);
 	}
-- 
2.25.1
Re: [PATCH] scsi: hpsa: add return value check for remap_pci_mem()
Posted by Markus Elfring 1 week, 6 days ago
> In hpsa_enter_performant_mode(), add return value check
> for remap_pci_mem() to prevent potential null pointer
> dereference.

* Would an other word wrapping be nicer?
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc7#n659

* How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?


Regards,
Markus