Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1488069
| From | Amit Shah <amit.shah@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection |
| Date | 2016-09-21 14:20 +0200 |
| Message-ID | <sjOFj-sk-5@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <shiTg-1yN-29@gated-at.bofh.it> <shj2W-1R7-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi, On (Wed) 14 Sep 2016 [16:01:28], SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Wed, 14 Sep 2016 14:00:35 +0200 > > The kfree() function was called in up to five cases > by the init_vqs() function during error handling even if > the passed variable contained a null pointer. > > * Return directly after a call of the function "kmalloc_array" failed > at the beginning. > > * Split a condition check for memory allocation failures so that > each pointer from these function calls will be checked immediately. > > See also background information: > Topic "CWE-754: Improper check for unusual or exceptional conditions" > Link: https://cwe.mitre.org/data/definitions/754.html > > * Adjust jump targets according to the Linux coding style convention. So I've seen this series and I'm not yet sure how I feel about the patches - f.e. in this one, it adds more lines than it removes to achieve the same effect. I think the code is currently more readable than after these changes. And even if kfree is called multiple times, it isn't a huge bother -- it's error case anyway, very unlikely to trigger, but keeps everything very readble. Amit
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:00 +0200
[PATCH 01/11] virtio_console: Use kmalloc_array() in init_vqs() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 04/11] virtio_console: Rename jump labels in virtcons_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 09/11] virtio_console: Rename a jump label in __send_to_port() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 03/11] virtio_console: Rename a jump label in init() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 06/11] virtio_console: Rename a jump label in port_fops_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
Re: [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection Amit Shah <amit.shah@redhat.com> - 2016-09-21 14:20 +0200
Re: virtio_console: Less function calls in init_vqs() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-21 15:10 +0200
[PATCH 08/11] virtio_console: Rename jump labels in port_fops_write() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 10/11] virtio_console: Rename jump labels in alloc_buf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 05/11] virtio_console: Rename jump labels in add_port() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 07/11] virtio_console: Rename a jump label in port_fops_splice_write() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:10 +0200
[PATCH 11/11] virtio_console: Rename a jump label in five functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-14 16:20 +0200
csiph-web