Message ID | 1548057848-15136-19-git-send-email-rppt@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C63CA1390 for <patchwork-linux-mm@patchwork.kernel.org>; Mon, 21 Jan 2019 08:06:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3A9B20415 for <patchwork-linux-mm@patchwork.kernel.org>; Mon, 21 Jan 2019 08:06:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A41DF29D1B; Mon, 21 Jan 2019 08:06:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 252BC20415 for <patchwork-linux-mm@patchwork.kernel.org>; Mon, 21 Jan 2019 08:06:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 373DE8E0027; Mon, 21 Jan 2019 03:06:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2FB6F8E0025; Mon, 21 Jan 2019 03:06:19 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0748E0027; Mon, 21 Jan 2019 03:06:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id CFD3F8E0025 for <linux-mm@kvack.org>; Mon, 21 Jan 2019 03:06:18 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id s71so15340609pfi.22 for <linux-mm@kvack.org>; Mon, 21 Jan 2019 00:06:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=kGEoz9PqFrl8WF8g+AZPK28J9wib4/3qVxmODZ1mnNM=; b=nWXecFjH4HB+3T8VumNCH8jxYw0klTrQA+d0OZ0dHl+qX5ezA56qYkxuT4McY/SmS0 M5AgfU7hHzaybrvQpmXGDDao1s1SR2ac01D4Pk96E5hg7IllniDfQTFl07Pr/btovd8G UzR1ICNoVHjw/UtzzfjeohkDdM4Sj2MtPAIUcag2SCt7q5ccrZvc+xgCe0hraMKXVyfp dHFJjDoEB19J4QW3aNrc2EJHDh42Cv2wgnaukPMcsV0T+JTyiN8ipQZHnrPJkR6pMNhf nizKsZezoDgfMuLflyJvB8naWzy4rwg3gZQvPpF7AXgjQKL8F8hS3Ig9OkO9+bryDXdh FoBg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AJcUukeLIbIjBFrQSTCa0UncKRcwqaP/GlJfJTl6QMupyyV3FyAGFPfq AOMDKakQbK2WHNEzK/yd3hcuwHK3mCCxyj8LFSveHx58PzLVSjKoIsul9qzBRt8VoqqgcDfDL+d szNkt9I974xvALsQod0UTPUIx2p0FfjoWMVDqiAZ/C21gOX3jspxJDD+/RyL/IAIVwg== X-Received: by 2002:a62:de06:: with SMTP id h6mr29662576pfg.158.1548057978510; Mon, 21 Jan 2019 00:06:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN74YGnzvfLVUWDncQXu4BMrztxbKPrrH286/rLLTRnWSEbaULOFW2whH6vDonpjpQ6FKDBW X-Received: by 2002:a62:de06:: with SMTP id h6mr29662540pfg.158.1548057977808; Mon, 21 Jan 2019 00:06:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057977; cv=none; d=google.com; s=arc-20160816; b=EaesPYM3gByZF4o1Xq5PRh4fCRAWGhmlS2es4vrYb7h0osaF6M1Al34PunNerxUkSF Gsd6dTZbE5OEpqr1aoEF2ZhlubDw08S98buNYybtKTRn+zHoE4cE9X9CBod2bYRh1adc zoT5Ag+X4/yrcGwxMPqWjnmhaStM2XRrmjxlKtrhe+ir8rIZxYwkgShkBR3/xmRVE1As V3GP1EOlOdnczmbSUecKaodYlx6rAHwyI5GxOhZCyF7QailvlsvHlIv4+HMJAXuuzgtw ksiZovFTN7rRa+WysCGF7XTnFC/NLMR5kFhfirYE5277+ifHjBQTB1r+o60KbH2ixout if4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from; bh=kGEoz9PqFrl8WF8g+AZPK28J9wib4/3qVxmODZ1mnNM=; b=WFHKlwk4Ahh4Ba7f6NT+DRWhHQuZ5J4HAu9ehF/JC71m6q3Ka+sbO9dDFR0PVXEiwj vGXl9DtS9QfUKFtQt7Afx8em0SJ9fB1AYG9w0U898g0ifxSa9522RNnh7TojIAQrm0bF K2xqPY/hv13+Nizxto3Qn64a7CJhlOVrXPNo2pbQCmHyTl+LXtwx6OTIrVEGHb6mas46 lPogchazv1gMksnXO5hPJ6K8UFsv3zl+jXhlPRlel8N7FteDVzRHoB9hMYSl99j9WsLk VtbgkV+jCLhatLJsBdD+rOGK4/4TG5hy0NPBOBCyepeKHmvmc3mkwnUmMfNiXfO+I5SG 5j4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id f23si10992876pgv.431.2019.01.21.00.06.17 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:06:17 -0800 (PST) Received-SPF: pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0L83rLU038722 for <linux-mm@kvack.org>; Mon, 21 Jan 2019 03:06:17 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q58e74nw4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for <linux-mm@kvack.org>; Mon, 21 Jan 2019 03:06:17 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for <linux-mm@kvack.org> from <rppt@linux.ibm.com>; Mon, 21 Jan 2019 08:06:13 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 21 Jan 2019 08:06:02 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0L861MI6422858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 Jan 2019 08:06:01 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 674FEA405D; Mon, 21 Jan 2019 08:06:01 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77FA6A4053; Mon, 21 Jan 2019 08:05:56 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.207.125]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 21 Jan 2019 08:05:56 +0000 (GMT) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 21 Jan 2019 10:05:55 +0200 From: Mike Rapoport <rppt@linux.ibm.com> To: linux-mm@kvack.org Cc: Andrew Morton <akpm@linux-foundation.org>, Catalin Marinas <catalin.marinas@arm.com>, Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Dennis Zhou <dennis@kernel.org>, Geert Uytterhoeven <geert@linux-m68k.org>, Greentime Hu <green.hu@gmail.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Guan Xuetao <gxt@pku.edu.cn>, Guo Ren <guoren@kernel.org>, Heiko Carstens <heiko.carstens@de.ibm.com>, Mark Salter <msalter@redhat.com>, Matt Turner <mattst88@gmail.com>, Max Filippov <jcmvbkbc@gmail.com>, Michael Ellerman <mpe@ellerman.id.au>, Michal Simek <monstr@monstr.eu>, Paul Burton <paul.burton@mips.com>, Petr Mladek <pmladek@suse.com>, Rich Felker <dalias@libc.org>, Richard Weinberger <richard@nod.at>, Rob Herring <robh+dt@kernel.org>, Russell King <linux@armlinux.org.uk>, Stafford Horne <shorne@gmail.com>, Tony Luck <tony.luck@intel.com>, Vineet Gupta <vgupta@synopsys.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, devicetree@vger.kernel.org, kasan-dev@googlegroups.com, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org, linux-usb@vger.kernel.org, linux-xtensa@linux-xtensa.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, x86@kernel.org, xen-devel@lists.xenproject.org, Mike Rapoport <rppt@linux.ibm.com> Subject: [PATCH v2 18/21] swiotlb: add checks for the return value of memblock_alloc*() Date: Mon, 21 Jan 2019 10:04:05 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548057848-15136-1-git-send-email-rppt@linux.ibm.com> References: <1548057848-15136-1-git-send-email-rppt@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19012108-0012-0000-0000-000002EAB91F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012108-0013-0000-0000-00002121DEC1 Message-Id: <1548057848-15136-19-git-send-email-rppt@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-21_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=979 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901210066 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
Refine memblock API
|
expand
|
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index d636177..e78835c8 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -191,6 +191,7 @@ void __init swiotlb_update_mem_attributes(void) int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) { unsigned long i, bytes; + size_t alloc_size; bytes = nslabs << IO_TLB_SHIFT; @@ -203,12 +204,18 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE * between io_tlb_start and io_tlb_end. */ - io_tlb_list = memblock_alloc( - PAGE_ALIGN(io_tlb_nslabs * sizeof(int)), - PAGE_SIZE); - io_tlb_orig_addr = memblock_alloc( - PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)), - PAGE_SIZE); + alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int)); + io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE); + if (!io_tlb_list) + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", + __func__, alloc_size, PAGE_SIZE); + + alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)); + io_tlb_orig_addr = memblock_alloc(alloc_size, PAGE_SIZE); + if (!io_tlb_orig_addr) + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", + __func__, alloc_size, PAGE_SIZE); + for (i = 0; i < io_tlb_nslabs; i++) { io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
Add panic() calls if memblock_alloc() returns NULL. The panic() format duplicates the one used by memblock itself and in order to avoid explosion with long parameters list replace open coded allocation size calculations with a local variable. Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> --- kernel/dma/swiotlb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)