linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] ACPI: pfr_update: Fix return value check in pfru_write()
@ 2022-01-06  7:54 Yang Yingliang
  2022-01-06  8:42 ` Chen Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-01-06  7:54 UTC (permalink / raw)
  To: linux-kernel, linux-acpi; +Cc: rafael, lenb, yu.c.chen

In case of error, memremap() returns NULL pointer not
ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: 0db89fa243e5 ("ACPI: Introduce Platform Firmware Runtime Update device driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/acpi/pfr_update.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pfr_update.c b/drivers/acpi/pfr_update.c
index 149b5b2530b9..6bb0b778b5da 100644
--- a/drivers/acpi/pfr_update.c
+++ b/drivers/acpi/pfr_update.c
@@ -460,8 +460,8 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,
 	/* map the communication buffer */
 	phy_addr = (phys_addr_t)((buf_info.addr_hi << 32) | buf_info.addr_lo);
 	buf_ptr = memremap(phy_addr, buf_info.buf_size, MEMREMAP_WB);
-	if (IS_ERR(buf_ptr))
-		return PTR_ERR(buf_ptr);
+	if (!buf_ptr)
+		return -ENOMEM;
 
 	if (!copy_from_iter_full(buf_ptr, len, &iter)) {
 		ret = -EINVAL;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] ACPI: pfr_update: Fix return value check in pfru_write()
  2022-01-06  7:54 [PATCH -next] ACPI: pfr_update: Fix return value check in pfru_write() Yang Yingliang
@ 2022-01-06  8:42 ` Chen Yu
  2022-01-06 17:55   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Yu @ 2022-01-06  8:42 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, linux-acpi, rafael, lenb

On Thu, Jan 06, 2022 at 03:54:48PM +0800, Yang Yingliang wrote:
> In case of error, memremap() returns NULL pointer not
> ERR_PTR(). The IS_ERR() test in the return value check
> should be replaced with NULL test.
> 
> Fixes: 0db89fa243e5 ("ACPI: Introduce Platform Firmware Runtime Update device driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/acpi/pfr_update.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/pfr_update.c b/drivers/acpi/pfr_update.c
> index 149b5b2530b9..6bb0b778b5da 100644
> --- a/drivers/acpi/pfr_update.c
> +++ b/drivers/acpi/pfr_update.c
> @@ -460,8 +460,8 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,
>  	/* map the communication buffer */
>  	phy_addr = (phys_addr_t)((buf_info.addr_hi << 32) | buf_info.addr_lo);
>  	buf_ptr = memremap(phy_addr, buf_info.buf_size, MEMREMAP_WB);
> -	if (IS_ERR(buf_ptr))
> -		return PTR_ERR(buf_ptr);
> +	if (!buf_ptr)
> +		return -ENOMEM;
>  
>  	if (!copy_from_iter_full(buf_ptr, len, &iter)) {
>  		ret = -EINVAL;
> -- 
> 2.25.1
>
Acked-by: Chen Yu <yu.c.chen@intel.com>

thanks,
Chenyu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] ACPI: pfr_update: Fix return value check in pfru_write()
  2022-01-06  8:42 ` Chen Yu
@ 2022-01-06 17:55   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-01-06 17:55 UTC (permalink / raw)
  To: Chen Yu, Yang Yingliang
  Cc: Linux Kernel Mailing List, ACPI Devel Maling List,
	Rafael J. Wysocki, Len Brown

On Thu, Jan 6, 2022 at 9:42 AM Chen Yu <yu.c.chen@intel.com> wrote:
>
> On Thu, Jan 06, 2022 at 03:54:48PM +0800, Yang Yingliang wrote:
> > In case of error, memremap() returns NULL pointer not
> > ERR_PTR(). The IS_ERR() test in the return value check
> > should be replaced with NULL test.
> >
> > Fixes: 0db89fa243e5 ("ACPI: Introduce Platform Firmware Runtime Update device driver")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> > ---
> >  drivers/acpi/pfr_update.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/pfr_update.c b/drivers/acpi/pfr_update.c
> > index 149b5b2530b9..6bb0b778b5da 100644
> > --- a/drivers/acpi/pfr_update.c
> > +++ b/drivers/acpi/pfr_update.c
> > @@ -460,8 +460,8 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,
> >       /* map the communication buffer */
> >       phy_addr = (phys_addr_t)((buf_info.addr_hi << 32) | buf_info.addr_lo);
> >       buf_ptr = memremap(phy_addr, buf_info.buf_size, MEMREMAP_WB);
> > -     if (IS_ERR(buf_ptr))
> > -             return PTR_ERR(buf_ptr);
> > +     if (!buf_ptr)
> > +             return -ENOMEM;
> >
> >       if (!copy_from_iter_full(buf_ptr, len, &iter)) {
> >               ret = -EINVAL;
> > --
> > 2.25.1
> >
> Acked-by: Chen Yu <yu.c.chen@intel.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-06 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  7:54 [PATCH -next] ACPI: pfr_update: Fix return value check in pfru_write() Yang Yingliang
2022-01-06  8:42 ` Chen Yu
2022-01-06 17:55   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).