From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chen Gang Subject: Re: [PATCH] arch: metag: kernel: dma.c: check 'pud' whether is NULL in dma_alloc_init() Date: Thu, 14 Nov 2013 17:35:29 +0800 Message-ID: <52849961.10502@asianux.com> References: <528485A9.5050509@asianux.com> <3903789.hqVScy5mZk@radagast> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <3903789.hqVScy5mZk@radagast> Sender: linux-metag-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: James Hogan Cc: qiuxishi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, Andrew Morton , linux-metag-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 11/14/2013 05:18 PM, James Hogan wrote: > On Thursday 14 November 2013 16:11:21 Chen Gang wrote: >> Like another p?d_alloc(), pud_alloc() also may fail, so need check it. >> >> Signed-off-by: Chen Gang > > NAK. > > pud_alloc folds to pud_offset on Meta so it cannot fail. > If so, can pmd_alloc() be fail? I checked the related definitions, it seems a little complex, can we assume p?d_alloc() are in the same condition? Thanks. > Cheers > James > >> --- >> arch/metag/kernel/dma.c | 5 +++++ >> 1 files changed, 5 insertions(+), 0 deletions(-) >> >> diff --git a/arch/metag/kernel/dma.c b/arch/metag/kernel/dma.c >> index db589ad..e6cf39b 100644 >> --- a/arch/metag/kernel/dma.c >> +++ b/arch/metag/kernel/dma.c >> @@ -398,6 +398,11 @@ static int __init dma_alloc_init(void) >> int offset = pgd_index(CONSISTENT_START); >> pgd = pgd_offset(&init_mm, CONSISTENT_START); >> pud = pud_alloc(&init_mm, pgd, CONSISTENT_START); >> + if (!pud) { >> + pr_err("%s: no pud tables\n", __func__); >> + ret = -ENOMEM; >> + break; >> + } >> pmd = pmd_alloc(&init_mm, pud, CONSISTENT_START); >> if (!pmd) { >> pr_err("%s: no pmd tables\n", __func__); > > -- Chen Gang -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html