From patchwork Tue Feb 28 09:34:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 6967 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0FC6523E01 for ; Tue, 28 Feb 2012 09:32:54 +0000 (UTC) Received: from mail-tul01m020-f180.google.com (mail-tul01m020-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id C8BD8A187B6 for ; Tue, 28 Feb 2012 09:32:53 +0000 (UTC) Received: by obbwd18 with SMTP id wd18so3203571obb.11 for ; Tue, 28 Feb 2012 01:32:53 -0800 (PST) Received: from mr.google.com ([10.50.156.225]) by 10.50.156.225 with SMTP id wh1mr15620829igb.0.1330421573077 (num_hops = 1); Tue, 28 Feb 2012 01:32:53 -0800 (PST) Received: by 10.50.156.225 with SMTP id wh1mr12737381igb.0.1330421573014; Tue, 28 Feb 2012 01:32:53 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.11.10 with SMTP id r10csp4181ibr; Tue, 28 Feb 2012 01:32:52 -0800 (PST) Received: by 10.204.155.154 with SMTP id s26mr7219216bkw.24.1330421571621; Tue, 28 Feb 2012 01:32:51 -0800 (PST) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id ah10si9704016bkc.19.2012.02.28.01.32.51 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Feb 2012 01:32:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) smtp.mail=dmitry.antipov@linaro.org Received: by mail-bk0-f50.google.com with SMTP id w11so2057176bku.37 for ; Tue, 28 Feb 2012 01:32:51 -0800 (PST) Received-SPF: pass (google.com: domain of dmitry.antipov@linaro.org designates 10.204.151.3 as permitted sender) client-ip=10.204.151.3; Received: from mr.google.com ([10.204.151.3]) by 10.204.151.3 with SMTP id a3mr9165719bkw.34.1330421571148 (num_hops = 1); Tue, 28 Feb 2012 01:32:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.151.3 with SMTP id a3mr7392285bkw.34.1330421570949; Tue, 28 Feb 2012 01:32:50 -0800 (PST) Received: from localhost.localdomain ([78.153.153.8]) by mx.google.com with ESMTPS id u8sm29800470bkg.13.2012.02.28.01.32.49 (version=SSLv3 cipher=OTHER); Tue, 28 Feb 2012 01:32:50 -0800 (PST) From: Dmitry Antipov To: Rusty Russell , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linaro-dev@lists.linaro.org, patches@linaro.org, Dmitry Antipov Subject: [PATCH 2/2] module: use ZERO_OR_NULL_PTR allocation pointer checking Date: Tue, 28 Feb 2012 13:34:00 +0400 Message-Id: <1330421640-5137-2-git-send-email-dmitry.antipov@linaro.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1330421640-5137-1-git-send-email-dmitry.antipov@linaro.org> References: <1330421640-5137-1-git-send-email-dmitry.antipov@linaro.org> X-Gm-Message-State: ALoCoQnllIUMGL3rOlvnev98f1tUkx1M4Jhd0SU0iVCeNttbOHDsKRs7wNtkla++HCsyB7XwYjpB Use ZERO_OR_NULL_PTR allocation pointer checking where allocation function may return ZERO_SIZE_PTR. --- kernel/module.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 2c93276..ae438db 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2322,14 +2322,14 @@ static void dynamic_debug_remove(struct _ddebug *debug) void * __weak module_alloc(unsigned long size) { - return size == 0 ? NULL : vmalloc_exec(size); + return vmalloc_exec(size); } static void *module_alloc_update_bounds(unsigned long size) { void *ret = module_alloc(size); - if (ret) { + if (likely(!ZERO_OR_NULL_PTR(ret))) { mutex_lock(&module_mutex); /* Update module bounds. */ if ((unsigned long)ret < module_addr_min) @@ -2638,7 +2638,7 @@ static int move_module(struct module *mod, struct load_info *info) * leak. */ kmemleak_not_leak(ptr); - if (!ptr) + if (unlikely(ZERO_OR_NULL_PTR(ptr))) return -ENOMEM; memset(ptr, 0, mod->core_size); @@ -2652,7 +2652,7 @@ static int move_module(struct module *mod, struct load_info *info) * after the module is initialized. */ kmemleak_ignore(ptr); - if (!ptr && mod->init_size) { + if (unlikely(ZERO_OR_NULL_PTR(ptr))) { module_free(mod, mod->module_core); return -ENOMEM; }