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:	Fri, 9 Oct 2015 11:58:48 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Chen Feng <puck.chen@...ilicon.com>
Cc:	dan.zhao@...ilicon.com, w.f@...wei.com, linuxarm@...wei.com,
	paul.gortmaker@...driver.com, sumit.semwal@...aro.org,
	devel@...verdev.osuosl.org, xuyiping@...ilicon.com,
	tapaswenipathak@...il.com, tranmanphong@...il.com,
	z.liuxinliang@...ilicon.com, kong.kongxinwei@...ilicon.com,
	qijiwen@...ilicon.com, weidong2@...ilicon.com,
	suzhuangluan@...ilicon.com, riandrews@...roid.com,
	gioh.kim@....com, gregkh@...uxfoundation.org,
	peter.panshilin@...ilicon.com, linux-kernel@...r.kernel.org,
	arve@...roid.com, saberlily.xia@...ilicon.com
Subject: Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC
 platform

On Fri, Oct 09, 2015 at 11:53:32AM +0300, Dan Carpenter wrote:
> > +out:
> 
> Labels named "out" are bug prone because handling everything is harder
> than using named labels and unwinding one step at a time.  The bug here
> is that we don't call ion_device_destroy().
> 
> > +	for (i = 0; i < num_heaps; ++i)
> > +		ion_heap_destroy(heaps[i]);
> > +	return err;
> 
> Write it like this:
> 
> err_free_heaps:
> 	for (i = 0; i < num_heaps; ++i)
> 		ion_heap_destroy(heaps[i]);
> err_free_idev:
> 	ion_device_destroy(idev);
> 
> 	return err;
> 
> > +}
> > +
> > +static int hi6220_ion_remove(struct platform_device *pdev)
> > +{
> > +	int i;
> > +
> > +	ion_device_destroy(idev);
> > +	for (i = 0; i < num_heaps; i++) {
> > +		if (!heaps[i])
> > +			continue;
> 
> We don't really need this NULL check and it isn't there in the
> hi6220_ion_probe() unwind code.
> 
> > +		ion_heap_destroy(heaps[i]);
> > +		heaps[i] = NULL;
> > +	}
> > +

Really the unwind from probe() and the remove() function should have
similar code.  For example, is it important to set heaps[i] to NULL?
If so then we should do it in the probe function as well.  If not then
we could leave it out of the remove function.

Also the ion_device_destroy(idev) should be after freeing heaps in the
remove function.

regards,
dan carpenter

--
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