Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757139AbXJ2Pda (ORCPT ); Mon, 29 Oct 2007 11:33:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752500AbXJ2PdW (ORCPT ); Mon, 29 Oct 2007 11:33:22 -0400 Received: from nf-out-0910.google.com ([64.233.182.190]:27375 "EHLO nf-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbXJ2PdV (ORCPT ); Mon, 29 Oct 2007 11:33:21 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WDKIy/z3Ukkt/GRqMyXM+JMnjzKBMZLjaeOVBEzc+utmmjgxbYCI2WWO25VDMB0BP/Oki1IPYuU2j2w4PuuG5RWTV6ewOAcpRiokBPRzzbl/d/i5LpvNdWJ7opuks0gX+EtoaKOkrW9Z3YhUWDazVqu3ULu9gfWmQer+wqOqy6o= Message-ID: Date: Mon, 29 Oct 2007 11:33:19 -0400 From: "Dmitry Torokhov" To: "Dirk Hohndel" Subject: Re: [PATCH] INPUT: fix hidinput_connect ignoring retval from input_register_device Cc: "Jeff Garzik" , "Jiri Kosina" , linux-input@atrey.karlin.mff.cuni.cz, linux-kernel@vger.kernel.org In-Reply-To: <20071029152050.GA23411@bigserver.hohndel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4725F2DF.1060500@garzik.org> <20071029152050.GA23411@bigserver.hohndel.org> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 858 Lines: 25 On 10/29/07, Dirk Hohndel wrote: > > Actually, the more I look at the code that bails when it runs out of memory, > the more I wonder about that. > > hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); > input_dev = input_allocate_device(); > if (!hidinput || !input_dev) { > kfree(hidinput); > input_free_device(input_dev); > > This either passes a NULL pointer to kfree or to input_free_device. That's > not nice. > No, that's allright. input_free_device() takes after kfree() so that it safe to call it with NULL pointer. -- Dmitry - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/