From patchwork Thu Jul 30 15:13:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vimal singh X-Patchwork-Id: 30388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id A4801B7B74 for ; Fri, 31 Jul 2009 01:16:37 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MWXKl-0004hr-Rs; Thu, 30 Jul 2009 15:14:19 +0000 Received: from mail-qy0-f181.google.com ([209.85.221.181]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MWXKf-0004he-IU for linux-mtd@lists.infradead.org; Thu, 30 Jul 2009 15:14:18 +0000 Received: by qyk11 with SMTP id 11so967156qyk.28 for ; Thu, 30 Jul 2009 08:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=bGvZNavsBt/Bq/nhf+qY4V95HGy8SEzF+nNJU7DRj8Y=; b=Z0VRLkEHaNV6PSK22X+99PWmwMUL46jtAHOyrW4sMM/bMI+J5ePMOk+dMJe/RxZazh AI9WHUMWAX22nlPENq6PMifaAQ37KHOQNrmL3UlmxnkZnPorusy9a//ivvnvruWvY+PP 8Ucr57wjKtonEdc/QM4JzWuUix7Lw0ZMv2aSk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=YixnuhCWrUHf/SOxqcO4/W4w+nKqbWV8jJDsPEHnO2rhO65NH460VMOqbsx4oHjk16 TFR7yY1hYZDXP1wIh2qrj8uYh4BGTBDLKSrSpPNkruxyX2Eo1iDgxKxkPvVq2SftafSI 2x5H5JjrOBidcShl4auVVK2GdPgJ/ebTTawpo= MIME-Version: 1.0 Received: by 10.229.97.194 with SMTP id m2mr242226qcn.21.1248966851486; Thu, 30 Jul 2009 08:14:11 -0700 (PDT) In-Reply-To: <4A71B401.1090208@linutronix.de> References: <1248958178-22599-1-git-send-email-sgayda2@uiuc.edu> <4A719A27.8050509@linutronix.de> <4A71A483.30507@linutronix.de> <4A71AD5E.4080704@uiuc.edu> <4A71B401.1090208@linutronix.de> From: vimal singh Date: Thu, 30 Jul 2009 20:43:51 +0530 Message-ID: Subject: Re: [PATCH] [mtd] fixed faulty check To: Sebastian Andrzej Siewior X-Spam-Score: 0.0 (/) Cc: Stoyan Gaydarov , kay.sievers@vrfy.org, gregkh@suse.de, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, sr@denx.de, David.Woodhouse@intel.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Thu, Jul 30, 2009 at 8:23 PM, Sebastian Andrzej Siewior wrote: > Stoyan Gaydarov wrote: >>>> >>>> We have to and of_flash_remove() takes care of it. >>>> >>> >>> >> >> Does this mean that the original patch is fine or does it still need the >> kfree? From what i understand when going to err_out it will take care of >> info using of_flash_remove() so then it is not needed in the if check. > > The original patch was fine but it leaked info. of_flash_remove() does the > cleanup of info but only if it is part of driver's data (after the > of_flash_remove()). So you have to call dev_set_drvdata(&dev->dev, info) > earlier, after the kzalloc() to save the data or else there is no clean > up. > Is this patch looks OK?? diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 39d357b..d104cfc 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c @@ -204,7 +204,7 @@ static int __devinit of_flash_probe(struct of_device *dev, dev_err(&dev->dev, "Malformed reg property on %s\n", dev->node->full_name); err = -EINVAL; - goto err_out; + goto err_flash_remove; } count /= reg_tuple_size; @@ -212,14 +212,14 @@ static int __devinit of_flash_probe(struct of_device *dev, info = kzalloc(sizeof(struct of_flash) + sizeof(struct of_flash_list) * count, GFP_KERNEL); if (!info) - goto err_out; - - mtd_list = kzalloc(sizeof(struct mtd_info) * count, GFP_KERNEL); - if (!info) - goto err_out; + goto err_flash_remove; dev_set_drvdata(&dev->dev, info); + mtd_list = kzalloc(sizeof(struct mtd_info) * count, GFP_KERNEL); + if (!mtd_list) + goto err_flash_remove; + for (i = 0; i < count; i++) { err = -ENXIO; if (of_address_to_resource(dp, i, &res)) { @@ -338,6 +338,7 @@ static int __devinit of_flash_probe(struct of_device *dev, err_out: kfree(mtd_list); +eerr_flash_remov: of_flash_remove(dev); return err;