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: 10438643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35911601D3 for ; Wed, 30 May 2018 11:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C0B52896A for ; Wed, 30 May 2018 11:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20AA528971; Wed, 30 May 2018 11:29:45 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 88DE02896A for ; Wed, 30 May 2018 11:29:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 237916B026E; Wed, 30 May 2018 07:29:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1E7B16B026F; Wed, 30 May 2018 07:29:43 -0400 (EDT) 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 0FFB86B0271; Wed, 30 May 2018 07:29:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id C369E6B026E for ; Wed, 30 May 2018 07:29:42 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id x21-v6so10661536pfn.23 for ; Wed, 30 May 2018 04:29:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=U2sauHCJ1eVIQqlvaA3cYU/NazJYGdm7/8Wkhq8ZNak=; b=AgP3fq+b3HbvzIMh7SbrQsIB61d+u6SdVNsUWegjeYXin8M98Q0LtNI9m3oRIbArfq 9o7J5Gm8PtPcKJlq3+GUCmzM2OXuYFnfB36YCZL4tfCvsJNcMiWPxhLMX7vNnjwdMQw/ wLTQYWFkmVtBhTfWeGJP7KlGcMs6ZMdVTGp/yCijob2qa+trrVoijtTKj3crKDhYERSK wo+ULPTRaIReMJDqXEU/sgICmoYr/nl6uzLHoLGR18Yq/lNnvRiWWJzk95/fQCVwtR9/ sw8Xh3Dv+0HaTSOhYFvC/aeUzY+WiRi9ivRVLQPBlh9CBXqgPhKAyW2DcnCK6yaRsVNN RKPA== X-Gm-Message-State: ALKqPwfj+kLzQmzYAnKa7khD4AHJOK6+b+K+irS9egJLbGBm+ZHT6K8d 6CnVEXKDWzKH7YMaunlKuimXYYg+bOPsGRfIIqGH4Xg4Tf2L/+Wvtq4/ZujFbvewwws46zA2IMm qtoMgSa3+1XJpui7g3E0P+Qtit08CLVMunSkliKnUufhZuq9HGaM7PCuyud14yjjn8XO2bT39H6 qcnIll21zXNa5YJ0reJBY0LZ4689Y7rvgLpMTGxA+7GUtYXcv449MSBH+fcZ8mQEIUktgHc4EAh 05glZuM3czNAKvBLZwTVjPf4EAcSar4l43o1Btr5obp7/cTw6KaZDthvcXMQC8aCssY6ONzbKS8 C3twYee8t49ObWDafDCnEl6Cj/bMHD9RFIONPG4P8bNWFbWqr2I/Es8a4uO0vrA01FdBwE/7RLo c X-Received: by 2002:a65:4dca:: with SMTP id q10-v6mr1961060pgt.22.1527679782484; Wed, 30 May 2018 04:29:42 -0700 (PDT) X-Received: by 2002:a65:4dca:: with SMTP id q10-v6mr1961039pgt.22.1527679781852; Wed, 30 May 2018 04:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527679781; cv=none; d=google.com; s=arc-20160816; b=Vfnd6WyKnno8wvvDvnlZSBhULyJRKl+SwULw8GLDZ0qJfCCd+2nF9yv+FSm5E3dAHY hlndfnBDTLyLY/jHjg5XS9MFh9sdStNcsxDU0Nfm/eMaXzyVflzrn8foQCuPvkvhhQPF k4RwKAJFNWISfLnVxEs+75M4cXWa3UT10u4mjBgEHEFArYn+yrpisMtC6QRf+Vz8+upY Kz9jTFDZJ6UFxyQjrVSaDawrSO7FO+QM0cI1t6zbeEmbdU0Yz8iiauXi0j8KCCmhbtqX f8y+g3igs9z3/9/bAYVplROKOdOLxBjid4GMcFpIJVA7XOLGnuuJqgOG6zt06FXq3vU0 8HBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=U2sauHCJ1eVIQqlvaA3cYU/NazJYGdm7/8Wkhq8ZNak=; b=BJJ60KgB/KeEPbR+/IhSWR78dygqB4u6Ih3xbXdUD0AvSho6TapHsMLY+KaVFskwvM rPfXet+iiXp/EOOns1Azd1GQdhdumV1p0OMQEwlonSIgnmR7Smw8AKPccB2JeYM++bne 2IyrIrbh0SXo8sFgPm0iPZsMFwJhtY3YaalGA6cjPA+XgvwP42AddxKJDWSbn2I9ziF6 tvpHgY/jw3xPlU36TU9UpGothTD+HC2rL7D9u2GViVXLKYf54tiWTjzLb/Z3O7akrt70 pDpYrLJueD1cAO7I0EHzAWNfuP8Al1iJJmYPIc+leGfd3xEqpZbLM4qLauJBMRBdu/sL golg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEpNoyfB; spf=pass (google.com: domain of baolin.wang@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=baolin.wang@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s65-v6sor11478205pfj.137.2018.05.30.04.29.41 for (Google Transport Security); Wed, 30 May 2018 04:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of baolin.wang@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEpNoyfB; spf=pass (google.com: domain of baolin.wang@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=baolin.wang@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-Smtp-Source: ADUXVKJRHoQ2/QMRDDw3Qap3CUP+Khv5tDXQOYbfu/4rqSECsBHNYOLraKfPbvQllPJzusXfm0lD0g== 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 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: X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;