From patchwork Thu Jan 23 09:56:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 3527311 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CB049F1C3 for ; Thu, 23 Jan 2014 09:56:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 718332017A for ; Thu, 23 Jan 2014 09:56:52 +0000 (UTC) Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA91220181 for ; Thu, 23 Jan 2014 09:56:50 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s0N9uog4030513 for ; Thu, 23 Jan 2014 03:56:50 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s0N9un8W025601 for ; Thu, 23 Jan 2014 03:56:49 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Thu, 23 Jan 2014 03:56:49 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s0N9ungd001099 for ; Thu, 23 Jan 2014 03:56:49 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 9046080626 for ; Thu, 23 Jan 2014 03:56:49 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlelxv84.itg.ti.com (dlelxv84.itg.ti.com [172.17.0.246]) by linux.omap.com (Postfix) with ESMTP id C05FF80626 for ; Thu, 23 Jan 2014 03:56:40 -0600 (CST) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dlelxv84.itg.ti.com (8.14.3/8.13.8) with ESMTP id s0N9ueQa001389 for ; Thu, 23 Jan 2014 03:56:40 -0600 Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id s0N9ue1O026627 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Jan 2014 03:56:40 -0600 Received: from [216.82.253.67:18729] by server-9.bemta-7.messagelabs.com id A4/E0-08480-857E0E25; Thu, 23 Jan 2014 09:56:40 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-16.tower-158.messagelabs.com!1390470998!6432557!1 X-Originating-IP: [209.85.192.181] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29262 invoked from network); 23 Jan 2014 09:56:39 -0000 Received: from mail-pd0-f181.google.com (HELO mail-pd0-f181.google.com) (209.85.192.181) by server-16.tower-158.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jan 2014 09:56:39 -0000 Received: by mail-pd0-f181.google.com with SMTP id y10so1566537pdj.26 for ; Thu, 23 Jan 2014 01:56: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=BjNg9MoljtGJv8oO4WY/SpE/m4W4d1bzAbYvSkdqQFc=; b=aEoya8sY8cO3u0LQb5Z6Qm5f6ANUZHMRDxKsFhclqAT6lQeGWgcewoW9Q8JZ2M7HTw EVbEBUr2JmBNTyqV0Tv2+o6vDcD+IqEhs+Wc204dGMBAZBkbynOM4CJeLj8PvTUzbUlP ZxuT31oF2BBDdlmzrKJiN6Y2uOdZTujKXSuu773HkxKRTDgYHs1XgehLnpA9MgqXZaHD NOCeJCa2JWFt3xTzp7VJhBjCK/+m7MDvMmTADOsK2m8LeugcTLyfcX+eCZn8pteH/eiG YouTP2oF/r+zuMpK1TUGR3a4MrrVKdpEdwIL0Qey9ZnVHZSCOkkDNqJxB31LTal3/wMN xjfg== X-Received: by 10.68.14.38 with SMTP id m6mr7180522pbc.60.1390470998634; Thu, 23 Jan 2014 01:56:38 -0800 (PST) Received: from tango-charlie.vayavyatech.com ([59.98.241.145]) by mx.google.com with ESMTPSA id oa3sm34240998pbb.15.2014.01.23.01.56.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 01:56:37 -0800 (PST) From: Prabhakar Lad To: Andrew Morton , Philipp Zabel , Nicolin Chen , Joe Perches Subject: [PATCH] lib/genalloc.c: add check gen_pool_dma_alloc() if dma pointer is not NULL Date: Thu, 23 Jan 2014 15:26:30 +0530 Message-ID: <1390470990-16065-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 CC: DLOS , LKML X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Lad, Prabhakar" In the gen_pool_dma_alloc() the dma pointer can be NULL and while assigning gen_pool_virt_to_phys(pool, vaddr) to dma caused the following crash on da850 evm, Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper Tainted: G W 3.13.0-rc1-00001-g0609e45-dirty #5 task: c4830000 ti: c4832000 task.ti: c4832000 PC is at gen_pool_dma_alloc+0x30/0x3c LR is at gen_pool_virt_to_phys+0x74/0x80 pc : [] lr : [] psr: 60000013 sp : c4833e38 ip : 00000000 fp : 00000000 r10: c0428928 r9 : c0430e1c r8 : c0444b70 r7 : c04436f0 r6 : c5840000 r5 : 00000000 r4 : c4802fe0 r3 : 80000000 r2 : c4833e18 r1 : c4832018 r0 : 80000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 0005317f Table: c0004000 DAC: 00000017 Process swapper (pid: 1, stack limit = 0xc48321c0) Stack: (0xc4833e38 to 0xc4834000) 3e20: c0443700 c0461668 3e40: c0017df4 c0413f00 c0208b14 c0443700 c0444b5c c0485910 00000000 c0208b30 3e60: c0208b14 c0443700 00000001 c02072e0 c0443700 c0444b70 c0443734 00000000 3e80: 0000004f c0207500 c0444b70 c0207474 c4833e98 c0205cc4 c4822258 c48c9150 3ea0: 00000000 c0444b70 c4b2d780 c0459270 c4822200 c020644c c03a30d4 c019547c 3ec0: c0444b70 c0444b70 00000000 c040f01c c040c5c0 c0207a90 00000000 c0444b5c 3ee0: 00000001 c0208a90 c4832000 00000000 c040f01c c041298c c4832000 c040f038 3f00: 00000000 c0008848 c485ca80 c0468954 c4833f44 c4833f78 00000000 c0102b00 3f20: 00000000 c485ca20 00000000 c052c52c c03f1160 c00346c8 00000003 60000013 3f40: c039e7e8 00000000 00000007 00000007 c0445ca0 c0428924 c0428924 00000008 3f60: c04612e0 c040c5c0 0000004f c0428928 00000000 c040c4f8 00000007 00000007 3f80: c040c5c0 c003f3b0 00000000 c03021f8 00000000 00000000 00000000 00000000 3fa0: 00000000 c0302200 00000000 c0009710 00000000 00000000 00000000 00000000 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000001 00000000 [] (gen_pool_dma_alloc+0x30/0x3c) from [] (davinci_pm_probe+0x40/0xa8) [] (davinci_pm_probe+0x40/0xa8) from [] (platform_drv_probe+0x1c/0x4c) [] (platform_drv_probe+0x1c/0x4c) from [] (driver_probe_device+0x98/0x22c) [] (driver_probe_device+0x98/0x22c) from [] (__driver_attach+0x8c/0x90) [] (__driver_attach+0x8c/0x90) from [] (bus_for_each_dev+0x6c/0x8c) [] (bus_for_each_dev+0x6c/0x8c) from [] (bus_add_driver+0x124/0x1d4) [] (bus_add_driver+0x124/0x1d4) from [] (driver_register+0x78/0xf8) [] (driver_register+0x78/0xf8) from [] (platform_driver_probe+0x20/0xa4) [] (platform_driver_probe+0x20/0xa4) from [] (davinci_init_late+0xc/0x14) [] (davinci_init_late+0xc/0x14) from [] (init_machine_late+0x1c/0x28) [] (init_machine_late+0x1c/0x28) from [] (do_one_initcall+0x34/0x15c) [] (do_one_initcall+0x34/0x15c) from [] (kernel_init_freeable+0xe4/0x1ac) [] (kernel_init_freeable+0xe4/0x1ac) from [] (kernel_init+0x8/0xec) [] (kernel_init+0x8/0xec) from [] (ret_from_fork+0x14/0x24) Code: 0afffffa e1a00004 e1a01006 ebfffef2 (e5850000) ---[ end trace 24fd42a15d1cdd7d ]--- This patch fixes the above. Signed-off-by: Lad, Prabhakar --- lib/genalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/genalloc.c b/lib/genalloc.c index dda3116..f48163f 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -334,7 +334,8 @@ void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) if (!vaddr) return NULL; - *dma = gen_pool_virt_to_phys(pool, vaddr); + if (dma) + *dma = gen_pool_virt_to_phys(pool, vaddr); return (void *)vaddr; }