[PATCH 7/9] menu: fix memory corruption

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Mon Aug 23 08:44:19 EDT 2010

On Mon, Aug 23, 2010 at 01:40:15PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 08:24 Mon 23 Aug     , Sascha Hauer wrote:
> > menu_free and menu_entry_free are called on not fully initialized
> > entries, so we have to check for validity before freeing the
> > members.
> > 
> I disagree free is suposed to not fail evenif we pass a NULL pointer
Ack.  (ie. free must accept NULL without barfing.)

free(3) has this feature:

	"free() frees the memory space pointed to by ptr [...].  If ptr
	 is NULL, no operation is performed."

and kfree in the kernel accepts NULL, too.

Best regards

Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

More information about the barebox mailing list