From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jake Oshins <jakeo@microsoft.com>
Cc: rafael.j.wysocki@intel.com, gregkh@linuxfoundation.org,
kys@microsoft.com, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com,
vkuznets@redhat.com
Subject: Re: [PATCH 2/3] drivers:hv Convert VMBus and its descendants to PnP
Date: Wed, 18 Feb 2015 13:24:07 +0300 [thread overview]
Message-ID: <20150218102407.GB5206@mwanda> (raw)
In-Reply-To: <1424202111-14461-2-git-send-email-jakeo@microsoft.com>
On Tue, Feb 17, 2015 at 11:41:50AM -0800, Jake Oshins wrote:
>
> + ret = pnp_add_descendant(child_device_obj->pnp_dev);
> if (ret)
> + goto register_exit;
> +
> + added = TRUE;
> +
> + ret = pnp_activate_dev(child_device_obj->pnp_dev);
> +
> +register_exit:
> +
> + if (ret) {
> + if (added)
> + pnp_remove_descendant(child_device_obj->pnp_dev);
> + free_pnp_descendant(child_device_obj->pnp_dev);
> pr_err("Unable to register child device\n");
> - else
> + } else
> pr_debug("child device %s registered\n",
> - dev_name(&child_device_obj->device));
> + dev_name(&child_device_obj->pnp_dev->dev));
>
> return ret;
> }
This error handling is horribly ugly and has a bug. Please, read my
essay on how to do error handling properly.
https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
1) Don't do "One Err" style error handling.
2) Don't twist the success path and the error paths together.
3) Don't use the "added" variable.
4) Don't initialize "ret" at the start of the function.
5) Don't forget to undo pnp_descendant_memory_option()
It should look something like:
return 0;
err_remove_desc:
pnp_remove_descendant(child_device_obj->pnp_dev);
err_remove_option:
if (bytes)
remove_whatever();
err_free_desc:
free_pnp_descendant(child_device_obj->pnp_dev);
return ret;
regards,
dan carpenter
next prev parent reply other threads:[~2015-02-18 10:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 19:41 [PATCH 1/3] drivers:pnp Add support for descendants claiming memory address space Jake Oshins
2015-02-17 19:41 ` [PATCH 2/3] drivers:hv Convert VMBus and its descendants to PnP Jake Oshins
2015-02-18 10:24 ` Dan Carpenter [this message]
2015-02-18 16:55 ` Jake Oshins
2015-02-17 19:41 ` [PATCH 3/3] drivers:hv Remove old MMIO management code Jake Oshins
2015-03-02 3:33 ` [PATCH 1/3] drivers:pnp Add support for descendants claiming memory address space Greg KH
2015-03-02 3:36 ` KY Srinivasan
2015-03-05 23:03 ` Rafael J. Wysocki
2015-03-10 22:10 ` Jake Oshins
2015-03-11 0:34 ` Rafael J. Wysocki
2015-03-19 19:21 ` Jake Oshins
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=20150218102407.GB5206@mwanda \
--to=dan.carpenter@oracle.com \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=jakeo@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=rafael.j.wysocki@intel.com \
--cc=vkuznets@redhat.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