From patchwork Sun Jan 11 13:07:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 427464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29628140182 for ; Mon, 12 Jan 2015 00:09:41 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YAIFQ-0003IY-EG; Sun, 11 Jan 2015 13:08:04 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YAIFN-0003El-4K for linux-mtd@lists.infradead.org; Sun, 11 Jan 2015 13:08:02 +0000 Received: by mail-pa0-f54.google.com with SMTP id fb1so27262734pad.13 for ; Sun, 11 Jan 2015 05:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=5Gdnm1dJI857Qv45WxFeolbNn1kHwyLBCK/j5nUKt6o=; b=M0SryBs9nTCdMt3A/EHeVy2uS8WF4w3WWG4uAXFywHfYeNzmd3y3wPz+JlVh5C/9Wu gMbIgDGYpTxWzKSKOjXU/ES7y72jKkbX7QgkrUWhHmVpLRC4kFRsUc1cZRnhJrpqt8YB emfeUjdqFB7TVCDYNibQK3rNBl0B8Lg8ZoKdK2RSm9Xff/A06AH8RzAgJH1K67Sk+i/6 KKxRJq1iYgDyzxaPDMfXBdwMAZ8Ybr5oN8WM98p7Af0S90i3ap+49+kNqoOxF5xDNwiR dJo8vQrwoxgGObE3GF5NtO6IXgL7LZNKFVeUfZjv/ND6vZWVuPGGm8QKCgEmiglds1cH jCBQ== X-Received: by 10.68.238.234 with SMTP id vn10mr36918474pbc.140.1420981658638; Sun, 11 Jan 2015 05:07:38 -0800 (PST) Received: from localhost.localdomain (KD106168100169.ppp-bb.dion.ne.jp. [106.168.100.169]) by mx.google.com with ESMTPSA id gz6sm11793500pbc.38.2015.01.11.05.07.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Jan 2015 05:07:37 -0800 (PST) From: Akinobu Mita To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization Date: Sun, 11 Jan 2015 22:07:20 +0900 Message-Id: <1420981640-16495-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150111_050801_252118_38AA22BB X-CRM114-Status: GOOD ( 10.88 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:236 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (akinobu.mita[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Cc: Brian Norris , Jonathan McDowell , David Woodhouse , Akinobu Mita X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In initialization routine, mtd_info->owner is overwritten by memset() just after being initialized. This can be fixed by moving memset() calls to just before setting mtd_info->owner. But the memory region is allocated by kmalloc, so we can fix it by using kzalloc instead of kmalloc. Signed-off-by: Akinobu Mita Cc: Jonathan McDowell Cc: David Woodhouse Cc: Brian Norris Cc: linux-mtd@lists.infradead.org --- drivers/mtd/nand/ams-delta.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c index f1d555c..842f8fe 100644 --- a/drivers/mtd/nand/ams-delta.c +++ b/drivers/mtd/nand/ams-delta.c @@ -183,7 +183,7 @@ static int ams_delta_init(struct platform_device *pdev) return -ENXIO; /* Allocate memory for MTD device structure and private data */ - ams_delta_mtd = kmalloc(sizeof(struct mtd_info) + + ams_delta_mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); if (!ams_delta_mtd) { printk (KERN_WARNING "Unable to allocate E3 NAND MTD device structure.\n"); @@ -196,10 +196,6 @@ static int ams_delta_init(struct platform_device *pdev) /* Get pointer to private data */ this = (struct nand_chip *) (&ams_delta_mtd[1]); - /* Initialize structures */ - memset(ams_delta_mtd, 0, sizeof(struct mtd_info)); - memset(this, 0, sizeof(struct nand_chip)); - /* Link the private data with the MTD structure */ ams_delta_mtd->priv = this;