From: Christophe JAILLET <christophe.jail...@wanadoo.fr>

commit a50bd64616907ed126ffbdbaa06c5ce708c4a404 upstream.

mpt3sas_get_port_by_id() can be called when a spinlock is held. Use
GFP_ATOMIC instead of GFP_KERNEL when allocating memory.

Issue spotted by call_kern.cocci:
./drivers/scsi/mpt3sas/mpt3sas_scsih.c:416:42-52: ERROR: function 
mpt3sas_get_port_by_id called on line 7125 inside lock on line 7123 but uses 
GFP_KERNEL
./drivers/scsi/mpt3sas/mpt3sas_scsih.c:416:42-52: ERROR: function 
mpt3sas_get_port_by_id called on line 6842 inside lock on line 6839 but uses 
GFP_KERNEL
./drivers/scsi/mpt3sas/mpt3sas_scsih.c:416:42-52: ERROR: function 
mpt3sas_get_port_by_id called on line 6854 inside lock on line 6851 but uses 
GFP_KERNEL
./drivers/scsi/mpt3sas/mpt3sas_scsih.c:416:42-52: ERROR: function 
mpt3sas_get_port_by_id called on line 7706 inside lock on line 7702 but uses 
GFP_KERNEL
./drivers/scsi/mpt3sas/mpt3sas_scsih.c:416:42-52: ERROR: function 
mpt3sas_get_port_by_id called on line 10260 inside lock on line 10256 but uses 
GFP_KERNEL

Link: 
https://lore.kernel.org/r/20210220093951.905362-1-christophe.jail...@wanadoo.fr
Fixes: 324c122fc0a4 ("scsi: mpt3sas: Add module parameter multipath_on_hba")
Signed-off-by: Christophe JAILLET <christophe.jail...@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.peter...@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -407,7 +407,7 @@ mpt3sas_get_port_by_id(struct MPT3SAS_AD
         * And add this object to port_table_list.
         */
        if (!ioc->multipath_on_hba) {
-               port = kzalloc(sizeof(struct hba_port), GFP_KERNEL);
+               port = kzalloc(sizeof(struct hba_port), GFP_ATOMIC);
                if (!port)
                        return NULL;
 


Reply via email to