From patchwork Wed May 30 11:28:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 137256 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp5195810lji; Wed, 30 May 2018 04:29:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJAYICNWb1BlmHeYXPoawKEbe3M+FBmmfEx9i0Mb7malvbdo64TridKC/438LC0YywO1ylc X-Received: by 2002:a17:902:7c95:: with SMTP id y21-v6mr2498701pll.76.1527679792723; Wed, 30 May 2018 04:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527679792; cv=none; d=google.com; s=arc-20160816; b=Pt14n+XpeLioVBeNLRDSvJP4WCgn0dGzPwtbUIpRaKrerdpHX3M5Es4iVOdIkasK8P 2oyWSMgGew8RGWGXSpBTuSYXo2+Yb5LbJwT0SNIq/50udmjCsXpJ5//hd57a6oz4ca3V c0HVYkfY3uyuCE+r8zoNNiofqLtAjrYW9cNr9vFCbCQS1fadAM6Ze0sGfbYEL6EscgP4 OyA+JUwkK21TB3AJk5ZqQnPrCU0GC/GocWqvxyH8szIqF/Lf1nz5nBXVJ4pnT0NRKoNb 3LI7OHrV+o2h+7Ut89eMAZSptnZtgVEx/xrwCTsraZThYnRGzFxqo0yxlF58EWjx+eGs kNJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=U2sauHCJ1eVIQqlvaA3cYU/NazJYGdm7/8Wkhq8ZNak=; b=qnk0lIbUwJVntGhddkIiuBc2ffE55IqGwr/0fuY0f2FjNDuFiru4q1enEvJONpxRUP USuFgXz+U2/NtB2FfyAcUe0bALaWxpA/ylPdIlJgEyuT99ySW1gerXxg4B4gf7fhf7Jj i9zXIPVJFCSB2SFmJuB0b7pmeUQMmd7pDejp/t48MgrjYlxcbIVw8pbCrie7BTL9hNdu 9OJ/8SUHB7T4vK0d8uOmVQ6HrOVxRSMdHeTYkObcLbnDd+XRjQOGeOVmiJ8eBtNWmNJl Qn5X7SCu5y9Sh4VUW/DfdcycAO2RIZNVSOQvE03quqYtryUZmDzg7Qm3E7AAOqs1eqri ndHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEpNoyfB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2-v6si10988975pgq.161.2018.05.30.04.29.52; Wed, 30 May 2018 04:29:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEpNoyfB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbeE3L3u (ORCPT + 30 others); Wed, 30 May 2018 07:29:50 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:41993 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752618AbeE3L3l (ORCPT ); Wed, 30 May 2018 07:29:41 -0400 Received: by mail-pf0-f195.google.com with SMTP id p14-v6so8882857pfh.9 for ; Wed, 30 May 2018 04:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=U2sauHCJ1eVIQqlvaA3cYU/NazJYGdm7/8Wkhq8ZNak=; b=aEpNoyfBfIUitS7jP2ZPpRlLfXjx9pSKAX7VBlLcxGTTA/rWEe7OeIgUKzBxA+hXm4 yklYQH+9ZU0RjeIpuBGFJU3GkY2Z60KUelDYUx7WS4YN0o4m2XhdLwzg8CgxBbCUjfV6 fYznFMhGTHa432MhldZVEKlgDXFLp7ad89xr0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=U2sauHCJ1eVIQqlvaA3cYU/NazJYGdm7/8Wkhq8ZNak=; b=qKHZJoFkexWrnQXuFGUy2pxapP8T9/YzEKeYoysYK8hDASRK0wXsTUba23vPtyuI0Z Kp7M5UQyClXtHCSTNozqNmf1W6+L10oYX9Lfq45HrpFJ/oyC67ThrGd9auGmzsIhmUtJ l974edjGdb4K8hKzKPMaucvpMySMo7p3wE9InvITZYVwy873/ZmDffsmeANzGLyJiQNw ZcW2KocX02X985Gw/QEsUAjdsRODxv4SU/oo0SeMwlPfaaIzRPb6y5KeQn67W0ckKUh9 czz48R5wWGOr0l/h9jAvzvK2Q8liL9Cq1wkJLHtCFHixEZYKF6M2RMf+fjm4yVTzsfMt dO4A== X-Gm-Message-State: ALKqPwdpVAn5yicxg4VqsklyAhAXpCyv9tNhb1NtFmofioFN7LLKTaln JkDG6MM5l4fOI610LRA5SJkvtA== X-Received: by 2002:a62:3f4f:: with SMTP id m76-v6mr2414628pfa.109.1527679781282; Wed, 30 May 2018 04:29:41 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id y20-v6sm18352504pge.46.2018.05.30.04.29.38 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 May 2018 04:29:40 -0700 (PDT) From: Baolin Wang To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH] mm: dmapool: Check the dma pool name Date: Wed, 30 May 2018 19:28:43 +0800 Message-Id: <59623b15001e5a20ac32b1a393db88722be2e718.1527679621.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It will be crash if we pass one NULL name when creating one dma pool, so we should check the passing name when copy it to dma pool. Moreover this patch replaces kmalloc_node() with kzalloc_node() to make sure the name array of dma pool is initialized in case the passing name is NULL. Signed-off-by: Baolin Wang --- mm/dmapool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/mm/dmapool.c b/mm/dmapool.c index 4d90a64..349f13d 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -155,11 +155,12 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev, else if ((boundary < size) || (boundary & (boundary - 1))) return NULL; - retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev)); + retval = kzalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev)); if (!retval) return retval; - strlcpy(retval->name, name, sizeof(retval->name)); + if (name) + strlcpy(retval->name, name, sizeof(retval->name)); retval->dev = dev;