lib: utils/irqchip: Add sanity checks in imsic_get_data() and imsic_get_target_file()
PATCH 1/1 lib: utils/irqchip: Add sanity checks in imsic_get_data() and imsic_get_target_file()
Add extra sanity checks to prevent the caller getting the invalid result from imsic_get_data() or imsic_get_target_file() when imsic is not initialized correctly.
--- lib/utils/irqchip/imsic.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/utils/irqchip/imsic.c +6 -0
@@ -123,6 +123,9 @@ struct imsic_data *imsic_get_data(u32 hartid) {struct sbi_scratch *scratch; +if (!imsic_ptr_offset) +return NULL ; + scratch =sbi_hartid_to_scratch (hartid);if (!scratch)return NULL ;
@@ -134,6 +137,9 @@ int imsic_get_target_file(u32 hartid) {struct sbi_scratch *scratch; +if (!imsic_file_offset) +return SBI_ENOENT ; + scratch =sbi_hartid_to_scratch (hartid);if (!scratch)return SBI_ENOENT ;
Signature · 1 line
2.39.3 (Apple Git-146)
PATCH 1/1 lib: utils/irqchip: Add sanity checks in imsic_get_data() and imsic_get_target_file()
Quoted 6 lines · On Thu, May 16, 2024 at 2:03?PM Cyan Yang <[email protected]> wrote:
Add extra sanity checks to prevent the caller getting the invalid result from
imsic_get_data()orimsic_get_target_file()when imsic is not initialized correctly.Signed-off-by Cyan Yang <[email protected]>
LGTM.
Regards,
Anup
Quoted 36 lines
--- lib/utils/irqchip/imsic.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/utils/irqchip/imsic.c +6
-1@@ -123,6 +123,9 @@ struct imsic_data *imsic_get_data(u32 hartid) {struct sbi_scratch *scratch; +if (!imsic_ptr_offset) +return NULL ; + scratch =sbi_hartid_to_scratch (hartid);if (!scratch)return NULL ;@@ -134,6 +137,9 @@ int imsic_get_target_file(u32 hartid) {struct sbi_scratch *scratch; +if (!imsic_file_offset) +return SBI_ENOENT ; + scratch =sbi_hartid_to_scratch (hartid);if (!scratch)return SBI_ENOENT ; --2.39.3 (Apple Git-146)
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
AppliedPATCH 1/1 lib: utils/irqchip: Add sanity checks in imsic_get_data() and imsic_get_target_file()
In reply to Cyan YangQuoted 6 lines · On Thu, May 16, 2024 at 2:03?PM Cyan Yang <[email protected]> wrote:
Add extra sanity checks to prevent the caller getting the invalid result from
imsic_get_data()orimsic_get_target_file()when imsic is not initialized correctly.Signed-off-by Cyan Yang <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 36 lines
--- lib/utils/irqchip/imsic.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/utils/irqchip/imsic.c +6
-1@@ -123,6 +123,9 @@ struct imsic_data *imsic_get_data(u32 hartid) {struct sbi_scratch *scratch; +if (!imsic_ptr_offset) +return NULL ; + scratch =sbi_hartid_to_scratch (hartid);if (!scratch)return NULL ;@@ -134,6 +137,9 @@ int imsic_get_target_file(u32 hartid) {struct sbi_scratch *scratch; +if (!imsic_file_offset) +return SBI_ENOENT ; + scratch =sbi_hartid_to_scratch (hartid);if (!scratch)return SBI_ENOENT ; --2.39.3 (Apple Git-146)
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi