From: Shuchang Li <lishuchang(a)hust.edu.cn>
stable inclusion
from stable-v5.15.111
commit fd8c83d8375b9dac1949f2753485a5c055ebfad0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7ZCDZ
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/dri…
--------------------------------
[ Upstream commit 91a0c0c1413239d0548b5aac4c82f38f6d53a91e ]
When if_type equals zero and pci_resource_start(pdev, PCI_64BIT_BAR4)
returns false, drbl_regs_memmap_p is not remapped. This passes a NULL
pointer to iounmap(), which can trigger a WARN() on certain arches.
When if_type equals six and pci_resource_start(pdev, PCI_64BIT_BAR4)
returns true, drbl_regs_memmap_p may has been remapped and
ctrl_regs_memmap_p is not remapped. This is a resource leak and passes a
NULL pointer to iounmap().
To fix these issues, we need to add null checks before iounmap(), and
change some goto labels.
Fixes: 1351e69fc6db ("scsi: lpfc: Add push-to-adapter support to sli4")
Signed-off-by: Shuchang Li <lishuchang(a)hust.edu.cn>
Link: https://lore.kernel.org/r/20230404072133.1022-1-lishuchang@hust.edu.cn
Reviewed-by: Justin Tee <justin.tee(a)broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen(a)oracle.com>
Signed-off-by: Yong Hu <yong.hu(a)windriver.com>
---
drivers/scsi/lpfc/lpfc_init.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 17200b453cbb..1bb3c96a04bd 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -10477,7 +10477,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
goto out_iounmap_all;
} else {
error = -ENOMEM;
- goto out_iounmap_all;
+ goto out_iounmap_ctrl;
}
}
@@ -10495,7 +10495,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
dev_err(&pdev->dev,
"ioremap failed for SLI4 HBA dpp registers.\n");
error = -ENOMEM;
- goto out_iounmap_ctrl;
+ goto out_iounmap_all;
}
phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p;
}
@@ -10520,9 +10520,11 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
return 0;
out_iounmap_all:
- iounmap(phba->sli4_hba.drbl_regs_memmap_p);
+ if (phba->sli4_hba.drbl_regs_memmap_p)
+ iounmap(phba->sli4_hba.drbl_regs_memmap_p);
out_iounmap_ctrl:
- iounmap(phba->sli4_hba.ctrl_regs_memmap_p);
+ if (phba->sli4_hba.ctrl_regs_memmap_p)
+ iounmap(phba->sli4_hba.ctrl_regs_memmap_p);
out_iounmap_conf:
iounmap(phba->sli4_hba.conf_regs_memmap_p);
--
2.33.0
From: Shuchang Li <lishuchang(a)hust.edu.cn>
stable inclusion
from stable-v5.15.131
commit fd8c83d8375b9dac1949f2753485a5c055ebfad0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7ZCDZ
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/dri…
--------------------------------
[ Upstream commit 91a0c0c1413239d0548b5aac4c82f38f6d53a91e ]
When if_type equals zero and pci_resource_start(pdev, PCI_64BIT_BAR4)
returns false, drbl_regs_memmap_p is not remapped. This passes a NULL
pointer to iounmap(), which can trigger a WARN() on certain arches.
When if_type equals six and pci_resource_start(pdev, PCI_64BIT_BAR4)
returns true, drbl_regs_memmap_p may has been remapped and
ctrl_regs_memmap_p is not remapped. This is a resource leak and passes a
NULL pointer to iounmap().
To fix these issues, we need to add null checks before iounmap(), and
change some goto labels.
Fixes: 1351e69fc6db ("scsi: lpfc: Add push-to-adapter support to sli4")
Signed-off-by: Shuchang Li <lishuchang(a)hust.edu.cn>
Link: https://lore.kernel.org/r/20230404072133.1022-1-lishuchang@hust.edu.cn
Reviewed-by: Justin Tee <justin.tee(a)broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen(a)oracle.com>
Signed-off-by: Yong Hu <yong.hu(a)windriver.com>
---
drivers/scsi/lpfc/lpfc_init.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 17200b453cbb..1bb3c96a04bd 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -10477,7 +10477,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
goto out_iounmap_all;
} else {
error = -ENOMEM;
- goto out_iounmap_all;
+ goto out_iounmap_ctrl;
}
}
@@ -10495,7 +10495,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
dev_err(&pdev->dev,
"ioremap failed for SLI4 HBA dpp registers.\n");
error = -ENOMEM;
- goto out_iounmap_ctrl;
+ goto out_iounmap_all;
}
phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p;
}
@@ -10520,9 +10520,11 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
return 0;
out_iounmap_all:
- iounmap(phba->sli4_hba.drbl_regs_memmap_p);
+ if (phba->sli4_hba.drbl_regs_memmap_p)
+ iounmap(phba->sli4_hba.drbl_regs_memmap_p);
out_iounmap_ctrl:
- iounmap(phba->sli4_hba.ctrl_regs_memmap_p);
+ if (phba->sli4_hba.ctrl_regs_memmap_p)
+ iounmap(phba->sli4_hba.ctrl_regs_memmap_p);
out_iounmap_conf:
iounmap(phba->sli4_hba.conf_regs_memmap_p);
--
2.33.0
Add OPENEULER_VERSION_CODE to version.h, so modules or applications
can identify the specific kernel version.
In most cases, the out-of-tree module needs to identify the release
version of the openEuler for interface adaptation. The existing
OPENEULER_VERSION() and OPENEULER_VERSION_CODE() cannot distinguish
between LTS versions and innovative versions. Therefore, a new macro
OPENEULER_LTS is introduced.
The version information is generated in "linux/version.h", as bellow:
include/generated/uapi/linux/version.h
```
#define OPENEULER_LTS 0 // 1: LTS; 0: none LTS
#define OPENEULER_MAJOR 9999 // OS Major version, 9999: none released
#define OPENEULER_MINOR 0 // SP release version
#define OPENEULER_VERSION(a,b) (((a) << 8) + (b))
#define OPENEULER_VERSION_CODE 2559744
```
Use Makefile.oever to avoid future merge conflicts.
https://gitee.com/openeuler/kernel/pulls/1442https://gitee.com/openeuler/kernel/issues/I7LEXYhttps://gitee.com/openeuler/kernel/issues/I575IThttps://gitee.com/openeuler/kernel/issues/I7761D
Xie XiuQi (1):
kernel: add OPENEULER_VERSION_CODE to version.h
---
v4: fix commit message format error for pr 1442
Makefile | 11 ++++++++++-
Makefile.oever | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 Makefile.oever
--
2.20.1
Add OPENEULER_VERSION_CODE to version.h, so modules or applications
can identify the specific kernel version.
In most cases, the out-of-tree module needs to identify the release
version of the openEuler for interface adaptation. The existing
OPENEULER_VERSION() and OPENEULER_VERSION_CODE() cannot distinguish
between LTS versions and innovative versions. Therefore, a new macro
OPENEULER_LTS is introduced.
The version information is generated in "linux/version.h", as bellow:
include/generated/uapi/linux/version.h
```
#define OPENEULER_LTS 0 // 1: LTS; 0: none LTS
#define OPENEULER_MAJOR 9999 // OS Major version, 9999: none released
#define OPENEULER_MINOR 0 // SP release version
#define OPENEULER_VERSION(a,b) (((a) << 8) + (b))
#define OPENEULER_VERSION_CODE 2559744
```
Use Makefile.oever to avoid future merge conflicts.
https://gitee.com/openeuler/kernel/pulls/1442https://gitee.com/openeuler/kernel/issues/I7LEXYhttps://gitee.com/openeuler/kernel/issues/I575IThttps://gitee.com/openeuler/kernel/issues/I7761D
Xie XiuQi (1):
kernel: add OPENEULER_VERSION_CODE to version.h
---
v2: fix commit message format error for pr 1442
Makefile | 11 ++++++++++-
Makefile.oever | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 Makefile.oever
--
2.20.1