mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vishnu Dasa <vdasa@vmware.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Jorgen Hansen <jhansen@vmware.com>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"dtor@vmware.com" <dtor@vmware.com>,
	Pv-drivers <Pv-drivers@vmware.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH 3/3] VMCI: Fix some error handling paths in vmci_guest_probe_device()
Date: Thu, 24 Feb 2022 16:08:25 +0000	[thread overview]
Message-ID: <5870CB73-6B33-43D2-926F-188EEB757A41@vmware.com> (raw)
In-Reply-To: <20220224100330.GO3943@kadam>



> On Feb 24, 2022, at 2:03 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> On Thu, Feb 24, 2022 at 06:53:10AM +0000, Vishnu Dasa wrote:
>> 
>>> On Feb 11, 2022, at 12:06 PM, Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
>>> 
>>> Le 11/02/2022 à 15:09, Dan Carpenter a écrit :
>>>> On Thu, Feb 10, 2022 at 11:27:34PM +0100, Christophe JAILLET wrote:
> 
>>>> Whatever...  But where this really
>>>> hurts is with:
>>>> Alloc:
>>>> 	if (vmci_dev->exclusive_vectors) {
>>>> 		error = request_irq(pci_irq_vector(pdev, 1), ...
>>>> Free:
>>>> 	free_irq(pci_irq_vector(pdev, 1), vmci_dev);
>>>> No if statement.  It works because it's the last allocation but it's
>>>> confusing and fragile.
>>> 
>>> Agreed.
>> 
>> Sorry, I hope I'm not missing something obvious or misunderstanding the point.
>> But I don't think the problem implied here exists?
>> 
>> If 'request_irq(pci_irq_vector(pdev, 0), ...' fails we goto err_disable_msi and there
>> is no free_irq in this path.  If 'request_irq(pci_irq_vector(pdev, 1), ...' fails then we
>> goto err_free_irq and we do 'free_irq(pci_irq_vector(pdev, 0), vmci_dev)'.  Note that
>> this is for the previous one without the check for vmci_dev->exclusive_vectors.
> 
> It's not a bug, but it's bad style.
> 
> Ideally the allocation code and the free code should mirror each other
> as much as possible.  If there is an if statement in the allocation code
> we should copy that same if statement into the free code.  Even if we
> can leave the if statement out, we should still include it for
> readability.
> 
> Also if we add another allocation at the end of the function then we
> will have to add the if statement back.  Maybe the person who adds the
> if statement will forget.  So it's fragile.

No disagreements about that.  Making sure I wasn't missing anything
else.

Could we have a separate fix for this which fixes?
"VMCI: dma dg: register dummy IRQ handlers for DMA datagrams"

Thanks!

  reply	other threads:[~2022-02-24 16:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 22:26 [PATCH 0/3] VMCI: Various fixes Christophe JAILLET
2022-02-10 22:27 ` [PATCH 1/3] VMCI: Fix the description of vmci_check_host_caps() Christophe JAILLET
2022-02-17  7:08   ` Vishnu Dasa
2022-02-10 22:27 ` [PATCH 2/3] VMCI: No need to clear memory after a dma_alloc_coherent() call Christophe JAILLET
2022-02-17  7:10   ` Vishnu Dasa
2022-02-10 22:27 ` [PATCH 3/3] VMCI: Fix some error handling paths in vmci_guest_probe_device() Christophe JAILLET
2022-02-11 14:09   ` Dan Carpenter
2022-02-11 20:06     ` Christophe JAILLET
2022-02-24  6:53       ` Vishnu Dasa
2022-02-24 10:03         ` Dan Carpenter
2022-02-24 16:08           ` Vishnu Dasa [this message]
2022-02-24  0:43   ` Vishnu Dasa

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=5870CB73-6B33-43D2-926F-188EEB757A41@vmware.com \
    --to=vdasa@vmware.com \
    --cc=Pv-drivers@vmware.com \
    --cc=arnd@arndb.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=dtor@vmware.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhansen@vmware.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®