From: Christian Borntraeger <borntraeger@de.ibm.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
"Cornelia Huck" <cornelia.huck@de.ibm.com>,
"David Hildenbrand" <dahi@linux.vnet.ibm.com>,
"Heiko Carstens" <heiko.carstens@de.ibm.com>,
"Martin Schwidefsky" <schwidefsky@de.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 3/4] KVM-S390: Less function calls in kvm_s390_import_bp_data() after error detection
Date: Wed, 24 Aug 2016 11:10:03 -0400 [thread overview]
Message-ID: <f9f50675-b283-4c03-8764-c7c570647fe4@de.ibm.com> (raw)
In-Reply-To: <47f88a11-b949-28ed-5589-925888a37574@users.sourceforge.net>
On 08/17/2016 02:10 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 17 Aug 2016 19:25:50 +0200
>
> The kfree() function was called in a few cases by the
> kvm_s390_import_bp_data() function during error handling
> even if a passed variable contained a null pointer.
>
> Adjust jump targets according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/s390/kvm/guestdbg.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
> index 8f886ee..f2514af 100644
> --- a/arch/s390/kvm/guestdbg.c
> +++ b/arch/s390/kvm/guestdbg.c
> @@ -239,7 +239,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
> wp_info = kmalloc(size, GFP_KERNEL);
> if (!wp_info) {
> ret = -ENOMEM;
> - goto error;
> + goto free_bp_data;
> }
> }
> size = nr_bp * sizeof(*bp_info);
> @@ -247,7 +247,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
> bp_info = kmalloc(size, GFP_KERNEL);
> if (!bp_info) {
> ret = -ENOMEM;
> - goto error;
> + goto free_wp_info;
> }
> }
>
> @@ -257,7 +257,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
> ret = __import_wp_info(vcpu, &bp_data[i],
> &wp_info[nr_wp]);
> if (ret)
> - goto error;
> + goto free_bp_info;
> nr_wp++;
> break;
> case KVM_HW_BP:
> @@ -273,10 +273,12 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
> vcpu->arch.guestdbg.nr_hw_wp = nr_wp;
> vcpu->arch.guestdbg.hw_wp_info = wp_info;
> return 0;
> -error:
> - kfree(bp_data);
> - kfree(wp_info);
> +free_bp_info:
> kfree(bp_info);
> +free_wp_info:
> + kfree(wp_info);
> +free_bp_data:
> + kfree(bp_data);
> return ret;
> }
I agree with Cornelia, while it seems correct from a technical point of view, it will
make the code harder to maintain. For example if we ever add a new malloc and remove
another one over time we would need to reshuffle the labels and this did went wrong
several times in the past.
Christian
next prev parent reply other threads:[~2016-08-24 15:10 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 18:02 [PATCH 0/4] KVM-S390: Fine-tuning for kvm_s390_import_bp_data() SF Markus Elfring
2016-08-17 18:06 ` [PATCH 1/4] KVM-S390: Improve determination of sizes in kvm_s390_import_bp_data() SF Markus Elfring
2016-08-18 7:25 ` walter harms
2016-08-18 9:02 ` Julia Lawall
2016-08-18 9:48 ` Paolo Bonzini
2016-08-18 10:52 ` walter harms
2016-08-18 10:55 ` Paolo Bonzini
2016-08-22 12:58 ` Cornelia Huck
2016-08-24 12:10 ` Replacing specific kmalloc() calls by kmalloc_array()? SF Markus Elfring
2016-08-24 15:00 ` Paolo Bonzini
2016-08-17 18:08 ` [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-22 13:02 ` David Hildenbrand
2016-08-22 13:05 ` Cornelia Huck
2016-08-24 15:19 ` Christian Borntraeger
2016-08-24 18:30 ` [PATCH v2 0/2] KVM: s390: Fine-tuning for kvm_s390_import_bp_data() SF Markus Elfring
2016-08-24 18:36 ` [PATCH v2 1/2] KVM: s390: Improve determination of sizes in kvm_s390_import_bp_data() SF Markus Elfring
2016-08-25 16:10 ` Cornelia Huck
2016-08-25 16:45 ` SF Markus Elfring
2016-08-25 17:34 ` Software evolution around scripts for the semantic patch langugae SF Markus Elfring
2016-08-25 17:40 ` Cornelia Huck
2016-08-25 17:54 ` SF Markus Elfring
2016-08-25 18:14 ` Julia Lawall
2016-08-25 18:20 ` SF Markus Elfring
2016-08-25 18:23 ` Julia Lawall
2016-08-25 21:04 ` Cornelia Huck
2016-08-24 18:40 ` [PATCH v2 2/2] KVM: s390: Use memdup_user() rather than duplicating code SF Markus Elfring
2016-08-25 16:11 ` Cornelia Huck
2016-10-03 12:11 ` Geert Uytterhoeven
2016-10-03 12:28 ` SF Markus Elfring
2016-10-03 13:10 ` Geert Uytterhoeven
2016-10-03 13:47 ` SF Markus Elfring
2016-10-03 14:00 ` Geert Uytterhoeven
2016-10-03 14:25 ` SF Markus Elfring
2016-08-25 16:12 ` [PATCH v2 0/2] KVM: s390: Fine-tuning for kvm_s390_import_bp_data() Christian Borntraeger
2016-08-17 18:10 ` [PATCH 3/4] KVM-S390: Less function calls in kvm_s390_import_bp_data() after error detection SF Markus Elfring
2016-08-22 12:58 ` David Hildenbrand
2016-08-22 13:00 ` Cornelia Huck
2016-08-22 16:56 ` SF Markus Elfring
2016-08-22 19:37 ` Cornelia Huck
2016-08-22 21:17 ` SF Markus Elfring
2016-08-22 21:28 ` Cornelia Huck
2016-08-31 12:29 ` Paolo Bonzini
2016-08-24 15:10 ` Christian Borntraeger [this message]
2016-08-27 16:12 ` SF Markus Elfring
2016-08-17 18:12 ` [PATCH 4/4] KVM-S390: Delete an unnecessary initialisation for a buffer variable SF Markus Elfring
2016-08-22 12:59 ` David Hildenbrand
2016-08-22 13:01 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f9f50675-b283-4c03-8764-c7c570647fe4@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=elfring@users.sourceforge.net \
--cc=heiko.carstens@de.ibm.com \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=schwidefsky@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).