Input: apanel: avoid panic if ioreamp fails
Subsystems (5)
PATCH 1/3 Input: apanel: avoid panic if ioreamp fails
If ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in check_signature().
Fix it by check the return value of ioremap.
--- drivers/input/misc/apanel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/misc/apanel.c +3 -1
@@ -259,7 +259,9 @@ static int __init apanel_init(void)unsigned char i2c_addr;int found =0 ; - bios =ioremap (0xF0000 ,0x10000 );/* Can't fail */ + bios =ioremap (0xF0000 ,0x10000 ); +if (!bios) +return -ENOMEM ; p =bios_signature (bios);if (!p) {
Signature · 1 line
2.20.1
PATCH 2/3 Input: wistron_btns: avoid panic if ioreamp fails
If ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in check_signature().
Fix it by check the return value of ioremap.
--- drivers/input/misc/wistron_btns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/input/misc/wistron_btns.c +4 -1
@@ -107,7 +107,10 @@ static int __init map_bios(void)ssize_t offset;u32 entry_point; - base =ioremap (0xF0000 ,0x10000 );/* Can't fail */ + base =ioremap (0xF0000 ,0x10000 ); +if (!base) +return -ENOMEM ; + offset =locate_wistron_bios (base);if (offset <0 ) {printk (KERN_ERR "wistron_btns: BIOS entry point not found\n" );
Signature · 1 line
2.20.1
PATCH 3/3 i2c: i801: avoid panic if ioreamp fails
In reply to Kefeng WangIf ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in check_signature().
Fix it by check the return value of ioremap.
--- drivers/i2c/busses/i2c-i801.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +4 -1
@@ -1068,7 +1068,10 @@ static void __init input_apanel_init(void)void __iomem *bios;const void __iomem *p; - bios =ioremap (0xF0000 ,0x10000 );/* Can't fail */ + bios =ioremap (0xF0000 ,0x10000 ); +if (!base) +return -ENOMEM ; + p =bios_signature (bios);if (p) {/* just use the first address */
Signature · 1 line
2.20.1
Re: [PATCH 3/3] i2c: i801: avoid panic if ioreamp fails
Hi Kefeng,
Quoted 20 lines · Kefeng Wang
If ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in
check_signature().Fix it by check the return value of ioremap.
Cc Jean Delvare <[email protected]>Cc Wolfram Sang <[email protected]>Reported-by Hulk Robot <[email protected]>Signed-off-by Kefeng Wang <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static void __init input_apanel_init(void) · line 1072
Quoted 6 lines
drivers/i2c/busses/i2c-i801.c +2
-1@@ -1068,7 +1068,10 @@ static void __init input_apanel_init(void)void __iomem *bios;const void __iomem *p; - bios =ioremap (0xF0000 ,0x10000 );/* Can't fail */ + bios =ioremap (0xF0000 ,0x10000 ); +if (!base)
That would be "if (!bios)". Please don't send patches without at least test-building the result.
We don't need this anyway. The comment says it can't fail, so why bother checking for a condition which will never happen?
Quoted 5 lines
drivers/i2c/busses/i2c-i801.c +2
-0+return -ENOMEM ; + p =bios_signature (bios);if (p) {/* just use the first address */
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH 3/3] i2c: i801: avoid panic if ioreamp fails
Quoted 26 lines · Jean Delvare
Hi Kefeng,
Quoted 23 lines · Kefeng Wang
If ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in
check_signature().Fix it by check the return value of ioremap.
Cc Jean Delvare <[email protected]>Cc Wolfram Sang <[email protected]>Reported-by Hulk Robot <[email protected]>Signed-off-by Kefeng Wang <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-i801.c +0
-0@@ -1068,7 +1068,10 @@ static void __init input_apanel_init(void)void __iomem *bios;const void __iomem *p;
Quoted 5 lines
drivers/i2c/busses/i2c-i801.c static void __init input_apanel_init(void) · line 1072
Quoted 3 lines
drivers/i2c/busses/i2c-i801.c +2
-1- bios =ioremap (0xF0000 ,0x10000 );/* Can't fail */ + bios =ioremap (0xF0000 ,0x10000 ); +if (!base)That would be "if (!bios)". Please don't send patches without at least test-building the result.
sorry, copy error.
Quoted 2 lines
We don't need this anyway. The comment says it can't fail, so why bother checking for a condition which will never happen?
The ioremap could fails due to no memory, our inner test robot(enable FAULT_INJECTION)
find this issue.
Quoted 7 lines
Quoted 6 lines
drivers/i2c/busses/i2c-i801.c +2
-0+return -ENOMEM ; + p =bios_signature (bios);if (p) {/* just use the first address */
Re: [PATCH 3/3] i2c: i801: avoid panic if ioreamp fails
Quoted 7 lines · Kefeng Wang
Quoted 2 lines · Jean Delvare
We don't need this anyway. The comment says it can't fail, so why bother checking for a condition which will never happen?
The ioremap could fails due to no memory, our inner test
robot(enable FAULT_INJECTION)find this issue.
The code only runs on x86 where this specific memory segment is standardized for the purpose. That's how we know it "can't fail".
That being said, maybe it could fail for other reasons (internal kernel bug, or bogus BIOS maybe), and I don't care adding the check anyway, as this code path is not performance critical.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH 3/3] i2c: i801: avoid panic if ioreamp fails
Quoted 6 lines · Jean Delvare
Quoted 5 lines · Kefeng Wang
Quoted 2 lines · Jean Delvare
We don't need this anyway. The comment says it can't fail, so why bother checking for a condition which will never happen?
The ioremap could fails due to no memory, our inner test
robot(enable FAULT_INJECTION)
Quoted 7 lines
Quoted 1 line
find this issue.
The code only runs on x86 where this specific memory segment is standardized for the purpose. That's how we know it "can't fail".
That being said, maybe it could fail for other reasons (internal kernel bug, or bogus BIOS maybe), and I don't care adding the check anyway, as this code path is not performance critical.
Got it , please ignore it.