* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 14:55 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-04-23 14:55 UTC (permalink / raw)
To: Dejin Zheng
Cc: gregkh, tglx, FlorianSchandinat, ralf, tsbogend, dri-devel,
linux-fbdev, linux-kernel, Andy Shevchenko
Hi,
I believe that the patch summary line should be:
"[PATCH v2] console: newport_con: ..."
On 4/23/20 4:26 PM, Dejin Zheng wrote:
> A call of the function ¡°do_take_over_console¡± can fail here.
> The corresponding system resources were not released then.
> Thus add a call of the function ¡°iounmap¡± together with the check
> of a failure predicate.
>
> Fixes: e84de0c6190503 ("MIPS: GIO bus support for SGI IP22/28")
I cannot see how this patch fixes commit e84de0c6190503
(AFAICS npregs has also been leaked on error before)?
> CC: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> ---
> v1 -> v2:
> - modify the commit comments by Markus'suggestion.
>
> drivers/video/console/newport_con.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
> index 00dddf6e08b0..6bfc8e3ffd4a 100644
> --- a/drivers/video/console/newport_con.c
> +++ b/drivers/video/console/newport_con.c
> @@ -720,6 +720,9 @@ static int newport_probe(struct gio_device *dev,
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> +
> + if (err)
> + iounmap((void *)npregs);
Looks OK but while you are at it, could you please also add missing
release_mem_region() on error and on device removal:
newport_addr = dev->resource.start + 0xF0000;
if (!request_mem_region(newport_addr, 0x10000, "Newport"))
return -ENODEV;
npregs = (struct newport_regs *)/* ioremap cannot fail */
ioremap(newport_addr, sizeof(struct newport_regs));
console_lock();
err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
console_unlock();
return err;
}
static void newport_remove(struct gio_device *dev)
{
give_up_console(&newport_con);
iounmap((void *)npregs);
}
?
> return err;
> }
>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 14:55 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-04-23 14:55 UTC (permalink / raw)
To: Dejin Zheng
Cc: linux-fbdev, tsbogend, FlorianSchandinat, gregkh, linux-kernel,
dri-devel, Andy Shevchenko, ralf, tglx
Hi,
I believe that the patch summary line should be:
"[PATCH v2] console: newport_con: ..."
On 4/23/20 4:26 PM, Dejin Zheng wrote:
> A call of the function ¡°do_take_over_console¡± can fail here.
> The corresponding system resources were not released then.
> Thus add a call of the function ¡°iounmap¡± together with the check
> of a failure predicate.
>
> Fixes: e84de0c6190503 ("MIPS: GIO bus support for SGI IP22/28")
I cannot see how this patch fixes commit e84de0c6190503
(AFAICS npregs has also been leaked on error before)?
> CC: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> ---
> v1 -> v2:
> - modify the commit comments by Markus'suggestion.
>
> drivers/video/console/newport_con.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
> index 00dddf6e08b0..6bfc8e3ffd4a 100644
> --- a/drivers/video/console/newport_con.c
> +++ b/drivers/video/console/newport_con.c
> @@ -720,6 +720,9 @@ static int newport_probe(struct gio_device *dev,
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> +
> + if (err)
> + iounmap((void *)npregs);
Looks OK but while you are at it, could you please also add missing
release_mem_region() on error and on device removal:
newport_addr = dev->resource.start + 0xF0000;
if (!request_mem_region(newport_addr, 0x10000, "Newport"))
return -ENODEV;
npregs = (struct newport_regs *)/* ioremap cannot fail */
ioremap(newport_addr, sizeof(struct newport_regs));
console_lock();
err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
console_unlock();
return err;
}
static void newport_remove(struct gio_device *dev)
{
give_up_console(&newport_con);
iounmap((void *)npregs);
}
?
> return err;
> }
>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
2020-04-23 14:55 ` Bartlomiej Zolnierkiewicz
(?)
@ 2020-04-23 15:05 ` Andy Shevchenko
-1 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2020-04-23 15:05 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: linux-fbdev, Thomas Bogendoerfer, FlorianSchandinat, Dejin Zheng,
Linux Kernel Mailing List, Ralf Baechle, dri-devel,
Greg Kroah-Hartman, Thomas Gleixner
On Thu, Apr 23, 2020 at 5:55 PM Bartlomiej Zolnierkiewicz
<b.zolnierkie@samsung.com> wrote:
> > + if (err)
> > + iounmap((void *)npregs);
>
> Looks OK but while you are at it, could you please also add missing
> release_mem_region() on error and on device removal:
>
> newport_addr = dev->resource.start + 0xF0000;
> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
> return -ENODEV;
>
> npregs = (struct newport_regs *)/* ioremap cannot fail */
> ioremap(newport_addr, sizeof(struct newport_regs));
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> return err;
> }
>
> static void newport_remove(struct gio_device *dev)
> {
> give_up_console(&newport_con);
> iounmap((void *)npregs);
> }
>
> ?
Don't you think that proper solution is rather switch to memremap()?
> > return err;
> > }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 15:05 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2020-04-23 15:05 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: Dejin Zheng, Greg Kroah-Hartman, Thomas Gleixner,
FlorianSchandinat, Ralf Baechle, Thomas Bogendoerfer, dri-devel,
linux-fbdev, Linux Kernel Mailing List
On Thu, Apr 23, 2020 at 5:55 PM Bartlomiej Zolnierkiewicz
<b.zolnierkie@samsung.com> wrote:
> > + if (err)
> > + iounmap((void *)npregs);
>
> Looks OK but while you are at it, could you please also add missing
> release_mem_region() on error and on device removal:
>
> newport_addr = dev->resource.start + 0xF0000;
> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
> return -ENODEV;
>
> npregs = (struct newport_regs *)/* ioremap cannot fail */
> ioremap(newport_addr, sizeof(struct newport_regs));
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> return err;
> }
>
> static void newport_remove(struct gio_device *dev)
> {
> give_up_console(&newport_con);
> iounmap((void *)npregs);
> }
>
> ?
Don't you think that proper solution is rather switch to memremap()?
> > return err;
> > }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 15:05 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2020-04-23 15:05 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: linux-fbdev, Thomas Bogendoerfer, FlorianSchandinat, Dejin Zheng,
Linux Kernel Mailing List, Ralf Baechle, dri-devel,
Greg Kroah-Hartman, Thomas Gleixner
On Thu, Apr 23, 2020 at 5:55 PM Bartlomiej Zolnierkiewicz
<b.zolnierkie@samsung.com> wrote:
> > + if (err)
> > + iounmap((void *)npregs);
>
> Looks OK but while you are at it, could you please also add missing
> release_mem_region() on error and on device removal:
>
> newport_addr = dev->resource.start + 0xF0000;
> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
> return -ENODEV;
>
> npregs = (struct newport_regs *)/* ioremap cannot fail */
> ioremap(newport_addr, sizeof(struct newport_regs));
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> return err;
> }
>
> static void newport_remove(struct gio_device *dev)
> {
> give_up_console(&newport_con);
> iounmap((void *)npregs);
> }
>
> ?
Don't you think that proper solution is rather switch to memremap()?
> > return err;
> > }
--
With Best Regards,
Andy Shevchenko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
2020-04-23 15:05 ` Andy Shevchenko
(?)
@ 2020-04-23 15:25 ` Bartlomiej Zolnierkiewicz
-1 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-04-23 15:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-fbdev, Thomas Bogendoerfer, FlorianSchandinat, Dejin Zheng,
Linux Kernel Mailing List, Ralf Baechle, dri-devel,
Greg Kroah-Hartman, Thomas Gleixner
On 4/23/20 5:05 PM, Andy Shevchenko wrote:
> On Thu, Apr 23, 2020 at 5:55 PM Bartlomiej Zolnierkiewicz
> <b.zolnierkie@samsung.com> wrote:
>
>>> + if (err)
>>> + iounmap((void *)npregs);
>>
>> Looks OK but while you are at it, could you please also add missing
>> release_mem_region() on error and on device removal:
>>
>> newport_addr = dev->resource.start + 0xF0000;
>> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
>> return -ENODEV;
>>
>> npregs = (struct newport_regs *)/* ioremap cannot fail */
>> ioremap(newport_addr, sizeof(struct newport_regs));
>> console_lock();
>> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
>> console_unlock();
>> return err;
>> }
>>
>> static void newport_remove(struct gio_device *dev)
>> {
>> give_up_console(&newport_con);
>> iounmap((void *)npregs);
>> }
>>
>> ?
>
> Don't you think that proper solution is rather switch to memremap()?
Doesn't seem to be a case here (used memory region in uncached).
On MIPS (this is MIPS-only driver):
...
#define ioremap(offset, size) \
__ioremap_mode((offset), (size), _CACHE_UNCACHED)
#define ioremap_uc ioremap
...
While memremap() is only for cacheable memory:
...
* memremap() - remap an iomem_resource as cacheable memory
* @offset: iomem resource start address
* @size: size of remap
* @flags: any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC,
* MEMREMAP_ENC, MEMREMAP_DEC
...
>>> return err;
>>> }
>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 15:25 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-04-23 15:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Dejin Zheng, Greg Kroah-Hartman, Thomas Gleixner,
FlorianSchandinat, Ralf Baechle, Thomas Bogendoerfer, dri-devel,
linux-fbdev, Linux Kernel Mailing List
On 4/23/20 5:05 PM, Andy Shevchenko wrote:
> On Thu, Apr 23, 2020 at 5:55 PM Bartlomiej Zolnierkiewicz
> <b.zolnierkie@samsung.com> wrote:
>
>>> + if (err)
>>> + iounmap((void *)npregs);
>>
>> Looks OK but while you are at it, could you please also add missing
>> release_mem_region() on error and on device removal:
>>
>> newport_addr = dev->resource.start + 0xF0000;
>> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
>> return -ENODEV;
>>
>> npregs = (struct newport_regs *)/* ioremap cannot fail */
>> ioremap(newport_addr, sizeof(struct newport_regs));
>> console_lock();
>> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
>> console_unlock();
>> return err;
>> }
>>
>> static void newport_remove(struct gio_device *dev)
>> {
>> give_up_console(&newport_con);
>> iounmap((void *)npregs);
>> }
>>
>> ?
>
> Don't you think that proper solution is rather switch to memremap()?
Doesn't seem to be a case here (used memory region in uncached).
On MIPS (this is MIPS-only driver):
...
#define ioremap(offset, size) \
__ioremap_mode((offset), (size), _CACHE_UNCACHED)
#define ioremap_uc ioremap
...
While memremap() is only for cacheable memory:
...
* memremap() - remap an iomem_resource as cacheable memory
* @offset: iomem resource start address
* @size: size of remap
* @flags: any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC,
* MEMREMAP_ENC, MEMREMAP_DEC
...
>>> return err;
>>> }
>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 15:25 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-04-23 15:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-fbdev, Thomas Bogendoerfer, FlorianSchandinat, Dejin Zheng,
Linux Kernel Mailing List, Ralf Baechle, dri-devel,
Greg Kroah-Hartman, Thomas Gleixner
On 4/23/20 5:05 PM, Andy Shevchenko wrote:
> On Thu, Apr 23, 2020 at 5:55 PM Bartlomiej Zolnierkiewicz
> <b.zolnierkie@samsung.com> wrote:
>
>>> + if (err)
>>> + iounmap((void *)npregs);
>>
>> Looks OK but while you are at it, could you please also add missing
>> release_mem_region() on error and on device removal:
>>
>> newport_addr = dev->resource.start + 0xF0000;
>> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
>> return -ENODEV;
>>
>> npregs = (struct newport_regs *)/* ioremap cannot fail */
>> ioremap(newport_addr, sizeof(struct newport_regs));
>> console_lock();
>> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
>> console_unlock();
>> return err;
>> }
>>
>> static void newport_remove(struct gio_device *dev)
>> {
>> give_up_console(&newport_con);
>> iounmap((void *)npregs);
>> }
>>
>> ?
>
> Don't you think that proper solution is rather switch to memremap()?
Doesn't seem to be a case here (used memory region in uncached).
On MIPS (this is MIPS-only driver):
...
#define ioremap(offset, size) \
__ioremap_mode((offset), (size), _CACHE_UNCACHED)
#define ioremap_uc ioremap
...
While memremap() is only for cacheable memory:
...
* memremap() - remap an iomem_resource as cacheable memory
* @offset: iomem resource start address
* @size: size of remap
* @flags: any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC,
* MEMREMAP_ENC, MEMREMAP_DEC
...
>>> return err;
>>> }
>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
2020-04-23 14:55 ` Bartlomiej Zolnierkiewicz
(?)
@ 2020-04-23 15:51 ` Dejin Zheng
-1 siblings, 0 replies; 21+ messages in thread
From: Dejin Zheng @ 2020-04-23 15:51 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: linux-fbdev, tsbogend, FlorianSchandinat, gregkh, linux-kernel,
dri-devel, Andy Shevchenko, ralf, tglx
On Thu, Apr 23, 2020 at 04:55:35PM +0200, Bartlomiej Zolnierkiewicz wrote:
>
> Hi,
>
> I believe that the patch summary line should be:
>
> "[PATCH v2] console: newport_con: ..."
>
OK, thanks!
> On 4/23/20 4:26 PM, Dejin Zheng wrote:
> > A call of the function ¡°do_take_over_console¡± can fail here.
> > The corresponding system resources were not released then.
> > Thus add a call of the function ¡°iounmap¡± together with the check
> > of a failure predicate.
> >
> > Fixes: e84de0c6190503 ("MIPS: GIO bus support for SGI IP22/28")
>
> I cannot see how this patch fixes commit e84de0c6190503
> (AFAICS npregs has also been leaked on error before)?
>
yes, you are right, the commit should be e86bb8acc0fdca82d2
("[PATCH] VT binding: Make newport_con support binding")
- move register ioremap from newport_startup() to newport_console_init()
> > CC: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> > ---
> > v1 -> v2:
> > - modify the commit comments by Markus'suggestion.
> >
> > drivers/video/console/newport_con.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
> > index 00dddf6e08b0..6bfc8e3ffd4a 100644
> > --- a/drivers/video/console/newport_con.c
> > +++ b/drivers/video/console/newport_con.c
> > @@ -720,6 +720,9 @@ static int newport_probe(struct gio_device *dev,
> > console_lock();
> > err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> > console_unlock();
> > +
> > + if (err)
> > + iounmap((void *)npregs);
>
> Looks OK but while you are at it, could you please also add missing
> release_mem_region() on error and on device removal:
>
Ok, Thanks, I will send the patch v3 for it.
> newport_addr = dev->resource.start + 0xF0000;
> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
> return -ENODEV;
>
> npregs = (struct newport_regs *)/* ioremap cannot fail */
> ioremap(newport_addr, sizeof(struct newport_regs));
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> return err;
> }
>
> static void newport_remove(struct gio_device *dev)
> {
> give_up_console(&newport_con);
> iounmap((void *)npregs);
> }
>
> ?
>
> > return err;
> > }
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 15:51 ` Dejin Zheng
0 siblings, 0 replies; 21+ messages in thread
From: Dejin Zheng @ 2020-04-23 15:51 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: gregkh, tglx, FlorianSchandinat, ralf, tsbogend, dri-devel,
linux-fbdev, linux-kernel, Andy Shevchenko
On Thu, Apr 23, 2020 at 04:55:35PM +0200, Bartlomiej Zolnierkiewicz wrote:
>
> Hi,
>
> I believe that the patch summary line should be:
>
> "[PATCH v2] console: newport_con: ..."
>
OK, thanks!
> On 4/23/20 4:26 PM, Dejin Zheng wrote:
> > A call of the function ¡°do_take_over_console¡± can fail here.
> > The corresponding system resources were not released then.
> > Thus add a call of the function ¡°iounmap¡± together with the check
> > of a failure predicate.
> >
> > Fixes: e84de0c6190503 ("MIPS: GIO bus support for SGI IP22/28")
>
> I cannot see how this patch fixes commit e84de0c6190503
> (AFAICS npregs has also been leaked on error before)?
>
yes, you are right, the commit should be e86bb8acc0fdca82d2
("[PATCH] VT binding: Make newport_con support binding")
- move register ioremap from newport_startup() to newport_console_init()
> > CC: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> > ---
> > v1 -> v2:
> > - modify the commit comments by Markus'suggestion.
> >
> > drivers/video/console/newport_con.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
> > index 00dddf6e08b0..6bfc8e3ffd4a 100644
> > --- a/drivers/video/console/newport_con.c
> > +++ b/drivers/video/console/newport_con.c
> > @@ -720,6 +720,9 @@ static int newport_probe(struct gio_device *dev,
> > console_lock();
> > err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> > console_unlock();
> > +
> > + if (err)
> > + iounmap((void *)npregs);
>
> Looks OK but while you are at it, could you please also add missing
> release_mem_region() on error and on device removal:
>
Ok, Thanks, I will send the patch v3 for it.
> newport_addr = dev->resource.start + 0xF0000;
> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
> return -ENODEV;
>
> npregs = (struct newport_regs *)/* ioremap cannot fail */
> ioremap(newport_addr, sizeof(struct newport_regs));
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> return err;
> }
>
> static void newport_remove(struct gio_device *dev)
> {
> give_up_console(&newport_con);
> iounmap((void *)npregs);
> }
>
> ?
>
> > return err;
> > }
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v2] console: console: Complete exception handling in newport_probe()
@ 2020-04-23 15:51 ` Dejin Zheng
0 siblings, 0 replies; 21+ messages in thread
From: Dejin Zheng @ 2020-04-23 15:51 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: linux-fbdev, tsbogend, FlorianSchandinat, gregkh, linux-kernel,
dri-devel, Andy Shevchenko, ralf, tglx
On Thu, Apr 23, 2020 at 04:55:35PM +0200, Bartlomiej Zolnierkiewicz wrote:
>
> Hi,
>
> I believe that the patch summary line should be:
>
> "[PATCH v2] console: newport_con: ..."
>
OK, thanks!
> On 4/23/20 4:26 PM, Dejin Zheng wrote:
> > A call of the function ¡°do_take_over_console¡± can fail here.
> > The corresponding system resources were not released then.
> > Thus add a call of the function ¡°iounmap¡± together with the check
> > of a failure predicate.
> >
> > Fixes: e84de0c6190503 ("MIPS: GIO bus support for SGI IP22/28")
>
> I cannot see how this patch fixes commit e84de0c6190503
> (AFAICS npregs has also been leaked on error before)?
>
yes, you are right, the commit should be e86bb8acc0fdca82d2
("[PATCH] VT binding: Make newport_con support binding")
- move register ioremap from newport_startup() to newport_console_init()
> > CC: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> > ---
> > v1 -> v2:
> > - modify the commit comments by Markus'suggestion.
> >
> > drivers/video/console/newport_con.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
> > index 00dddf6e08b0..6bfc8e3ffd4a 100644
> > --- a/drivers/video/console/newport_con.c
> > +++ b/drivers/video/console/newport_con.c
> > @@ -720,6 +720,9 @@ static int newport_probe(struct gio_device *dev,
> > console_lock();
> > err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> > console_unlock();
> > +
> > + if (err)
> > + iounmap((void *)npregs);
>
> Looks OK but while you are at it, could you please also add missing
> release_mem_region() on error and on device removal:
>
Ok, Thanks, I will send the patch v3 for it.
> newport_addr = dev->resource.start + 0xF0000;
> if (!request_mem_region(newport_addr, 0x10000, "Newport"))
> return -ENODEV;
>
> npregs = (struct newport_regs *)/* ioremap cannot fail */
> ioremap(newport_addr, sizeof(struct newport_regs));
> console_lock();
> err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
> console_unlock();
> return err;
> }
>
> static void newport_remove(struct gio_device *dev)
> {
> give_up_console(&newport_con);
> iounmap((void *)npregs);
> }
>
> ?
>
> > return err;
> > }
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 21+ messages in thread