lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Feb 2015 16:55:15 +0000
From:	Jake Oshins <jakeo@...rosoft.com>
To:	Dan Carpenter <dan.carpenter@...cle.com>
CC:	"rafael.j.wysocki@...el.com" <rafael.j.wysocki@...el.com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
	KY Srinivasan <kys@...rosoft.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"devel@...uxdriverproject.org" <devel@...uxdriverproject.org>,
	"olaf@...fle.de" <olaf@...fle.de>,
	"apw@...onical.com" <apw@...onical.com>,
	"vkuznets@...hat.com" <vkuznets@...hat.com>
Subject: RE: [PATCH 2/3] drivers:hv Convert VMBus and its descendants to PnP

> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@...cle.com]
> Sent: Wednesday, February 18, 2015 2:24 AM
> To: Jake Oshins
> Cc: rafael.j.wysocki@...el.com; gregkh@...uxfoundation.org; KY Srinivasan;
> linux-kernel@...r.kernel.org; devel@...uxdriverproject.org; olaf@...fle.de;
> apw@...onical.com; vkuznets@...hat.com
> Subject: Re: [PATCH 2/3] drivers:hv Convert VMBus and its descendants to PnP
> 
> 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


Will do.  Thanks for the review.

-- Jake Oshins

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ