* [PATCH 5/15] skeletonfb: check fb_alloc_cmap return value and handle failure properly
@ 2009-02-07 17:13 Andres Salomon
2009-02-09 6:29 ` [Linux-fbdev-devel] " Krzysztof Helt
0 siblings, 1 reply; 3+ messages in thread
From: Andres Salomon @ 2009-02-07 17:13 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, linux-fbdev-devel, adaplas
Bad example code, no cookie!
Signed-off-by: Andres Salomon <dilinger@debian.org>
---
drivers/video/skeletonfb.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
index df53365..a439159 100644
--- a/drivers/video/skeletonfb.c
+++ b/drivers/video/skeletonfb.c
@@ -795,8 +795,9 @@ static int __devinit xxxfb_probe(struct pci_dev *dev,
if (!retval || retval == 4)
return -EINVAL;
- /* This has to been done !!! */
- fb_alloc_cmap(&info->cmap, cmap_len, 0);
+ /* This has to be done! */
+ if (fb_alloc_cmap(&info->cmap, cmap_len, 0))
+ return -ENOMEM;
/*
* The following is done in the case of having hardware with a static
@@ -820,8 +821,10 @@ static int __devinit xxxfb_probe(struct pci_dev *dev,
*/
/* xxxfb_set_par(info); */
- if (register_framebuffer(info) < 0)
+ if (register_framebuffer(info) < 0) {
+ fb_dealloc_cmap(&info->cmap);
return -EINVAL;
+ }
printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
info->fix.id);
pci_set_drvdata(dev, info); /* or platform_set_drvdata(pdev, info) */
--
1.5.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Linux-fbdev-devel] [PATCH 5/15] skeletonfb: check fb_alloc_cmap return value and handle failure properly
2009-02-07 17:13 [PATCH 5/15] skeletonfb: check fb_alloc_cmap return value and handle failure properly Andres Salomon
@ 2009-02-09 6:29 ` Krzysztof Helt
2009-02-09 22:32 ` Andres Salomon
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Helt @ 2009-02-09 6:29 UTC (permalink / raw)
To: Andres Salomon; +Cc: Andrew Morton, linux-fbdev-devel, linux-kernel, adaplas
On Sat, 7 Feb 2009 12:13:02 -0500
Andres Salomon <dilinger@queued.net> wrote:
>
> Bad example code, no cookie!
>
It is even worse than you thought.
> Signed-off-by: Andres Salomon <dilinger@debian.org>
> ---
> drivers/video/skeletonfb.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
> index df53365..a439159 100644
> --- a/drivers/video/skeletonfb.c
> +++ b/drivers/video/skeletonfb.c
> @@ -795,8 +795,9 @@ static int __devinit xxxfb_probe(struct pci_dev *dev,
> if (!retval || retval == 4)
> return -EINVAL;
>
> - /* This has to been done !!! */
> - fb_alloc_cmap(&info->cmap, cmap_len, 0);
> + /* This has to be done! */
> + if (fb_alloc_cmap(&info->cmap, cmap_len, 0))
> + return -ENOMEM;
>
The info pointer should be freed before the return here ...
> /*
> * The following is done in the case of having hardware with a static
> @@ -820,8 +821,10 @@ static int __devinit xxxfb_probe(struct pci_dev *dev,
> */
> /* xxxfb_set_par(info); */
>
> - if (register_framebuffer(info) < 0)
> + if (register_framebuffer(info) < 0) {
> + fb_dealloc_cmap(&info->cmap);
... and here.
> return -EINVAL;
> + }
> printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
> info->fix.id);
> pci_set_drvdata(dev, info); /* or platform_set_drvdata(pdev, info) */
> --
Kind regards,
Krzysztof
----------------------------------------------------------------------
Zostan mistrzem parkowania w Bombaju!
Zagraj >> http://link.interia.pl/f204e
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Linux-fbdev-devel] [PATCH 5/15] skeletonfb: check fb_alloc_cmap return value and handle failure properly
2009-02-09 6:29 ` [Linux-fbdev-devel] " Krzysztof Helt
@ 2009-02-09 22:32 ` Andres Salomon
0 siblings, 0 replies; 3+ messages in thread
From: Andres Salomon @ 2009-02-09 22:32 UTC (permalink / raw)
To: Krzysztof Helt; +Cc: Andrew Morton, linux-fbdev-devel, linux-kernel, adaplas
On Mon, 9 Feb 2009 07:29:29 +0100
Krzysztof Helt <krzysztof.h1@poczta.fm> wrote:
> On Sat, 7 Feb 2009 12:13:02 -0500
> Andres Salomon <dilinger@queued.net> wrote:
>
> >
> > Bad example code, no cookie!
> >
>
> It is even worse than you thought.
Maybe skeletonfb.c should simply be dropped completely? Incorrect
documentation is worse than no documentation. If it's unmaintained,
buggy, and incorrect in many places...
>
> > Signed-off-by: Andres Salomon <dilinger@debian.org>
> > ---
> > drivers/video/skeletonfb.c | 9 ++++++---
> > 1 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
> > index df53365..a439159 100644
> > --- a/drivers/video/skeletonfb.c
> > +++ b/drivers/video/skeletonfb.c
> > @@ -795,8 +795,9 @@ static int __devinit xxxfb_probe(struct pci_dev
> > *dev, if (!retval || retval == 4)
> > return -EINVAL;
> >
> > - /* This has to been done !!! */
> > - fb_alloc_cmap(&info->cmap, cmap_len, 0);
> > + /* This has to be done! */
> > + if (fb_alloc_cmap(&info->cmap, cmap_len, 0))
> > + return -ENOMEM;
> >
>
> The info pointer should be freed before the return here ...
>
> > /*
> > * The following is done in the case of having hardware with a
> > static @@ -820,8 +821,10 @@ static int __devinit xxxfb_probe(struct
> > pci_dev *dev, */
> > /* xxxfb_set_par(info); */
> >
> > - if (register_framebuffer(info) < 0)
> > + if (register_framebuffer(info) < 0) {
> > + fb_dealloc_cmap(&info->cmap);
>
> ... and here.
>
> > return -EINVAL;
> > + }
> > printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
> > info->fix.id);
> > pci_set_drvdata(dev, info); /* or platform_set_drvdata(pdev,
> > info) */ --
>
>
> Kind regards,
> Krzysztof
>
>
> ----------------------------------------------------------------------
> Zostan mistrzem parkowania w Bombaju!
> Zagraj >> http://link.interia.pl/f204e
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-09 22:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-07 17:13 [PATCH 5/15] skeletonfb: check fb_alloc_cmap return value and handle failure properly Andres Salomon
2009-02-09 6:29 ` [Linux-fbdev-devel] " Krzysztof Helt
2009-02-09 22:32 ` Andres Salomon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox