drivers/video/pnx4008: eliminate double free

The function framebuffer_release just calls kfree, so calling kfree
subsequently on the same argument represents a double free. The comments with
the definition of framebuffer_release in drivers/video/fbsysfs.c suggest that
a more elaborate definition of this function is planned, such that the
splitting up of framebuffer_release and kfree as done in the second instance
might someday make sense, but it does not make sense now.

This was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression E;
@@

* kfree(E);
...
* framebuffer_release(E);

@@
expression E;
@@

* framebuffer_release(E);
...
* kfree(E);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Vitaly Wool <vitalywool@gmail.com>
Cc: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: Grigory Tolstolytkin <gtolstolytkin@ru.mvista.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Julia Lawall and committed by
Linus Torvalds
7a6278e5 5aecd559

+4 -7
+4 -7
drivers/video/pnx4008/pnxrgbfb.c
··· 100 fb_dealloc_cmap(&info->cmap); 101 framebuffer_release(info); 102 platform_set_drvdata(pdev, NULL); 103 - kfree(info); 104 } 105 106 pnx4008_free_dum_channel(channel_owned, pdev->id); ··· 167 168 ret = fb_alloc_cmap(&info->cmap, 256, 0); 169 if (ret < 0) 170 - goto err2; 171 172 ret = register_framebuffer(info); 173 if (ret < 0) 174 - goto err3; 175 platform_set_drvdata(pdev, info); 176 177 return 0; 178 179 - err3: 180 - fb_dealloc_cmap(&info->cmap); 181 err2: 182 - framebuffer_release(info); 183 err1: 184 pnx4008_free_dum_channel(channel_owned, pdev->id); 185 err0: 186 - kfree(info); 187 err: 188 return ret; 189 }
··· 100 fb_dealloc_cmap(&info->cmap); 101 framebuffer_release(info); 102 platform_set_drvdata(pdev, NULL); 103 } 104 105 pnx4008_free_dum_channel(channel_owned, pdev->id); ··· 168 169 ret = fb_alloc_cmap(&info->cmap, 256, 0); 170 if (ret < 0) 171 + goto err1; 172 173 ret = register_framebuffer(info); 174 if (ret < 0) 175 + goto err2; 176 platform_set_drvdata(pdev, info); 177 178 return 0; 179 180 err2: 181 + fb_dealloc_cmap(&info->cmap); 182 err1: 183 pnx4008_free_dum_channel(channel_owned, pdev->id); 184 err0: 185 + framebuffer_release(info); 186 err: 187 return ret; 188 }