From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Jean Delvare <jdelvare@suse.de>
Cc: linux-kernel@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>,
linux-i2c@vger.kernel.org, Hulk Robot <hulkci@huawei.com>
Subject: Re: [PATCH 3/3] i2c: i801: avoid panic if ioreamp fails
Date: Fri, 10 May 2019 17:35:46 +0800 [thread overview]
Message-ID: <164bb498-35dc-b226-4adb-3d743f4790a1@huawei.com> (raw)
In-Reply-To: <20190510100955.497a1a57@endymion>
On 2019/5/10 16:09, Jean Delvare wrote:
> Hi Kefeng,
>
> On Fri, 10 May 2019 11:03:20 +0800, Kefeng Wang wrote:
>> 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 <jdelvare@suse.com>
>> Cc: Wolfram Sang <wsa@the-dreams.de>
>> Cc: linux-i2c@vger.kernel.org
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> drivers/i2c/busses/i2c-i801.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
>> index 679c6c41f64b..fc6ccb8aba17 100644
>> --- a/drivers/i2c/busses/i2c-i801.c
>> +++ b/drivers/i2c/busses/i2c-i801.c
>> @@ -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.
sorry, copy error.
> 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.
>
>> + return -ENOMEM;
>> +
>> p = bios_signature(bios);
>> if (p) {
>> /* just use the first address */
>
next prev parent reply other threads:[~2019-05-10 9:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190510030320.109154-1-wangkefeng.wang@huawei.com>
2019-05-10 3:03 ` [PATCH 3/3] i2c: i801: avoid panic if ioreamp fails Kefeng Wang
2019-05-10 8:09 ` Jean Delvare
2019-05-10 9:35 ` Kefeng Wang [this message]
2019-05-10 12:18 ` Jean Delvare
2019-05-11 1:32 ` Kefeng Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=164bb498-35dc-b226-4adb-3d743f4790a1@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=hulkci@huawei.com \
--cc=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox