Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp130422imm; Wed, 30 May 2018 19:37:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIZ+N997FACcYvnGdprBk0AUlmP8XGjA2KB1c+wMbd6Nzp93KN3PXw+GdcXySfNshTxz3UJ X-Received: by 2002:a62:249b:: with SMTP id k27-v6mr5076699pfk.143.1527734271793; Wed, 30 May 2018 19:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527734271; cv=none; d=google.com; s=arc-20160816; b=AuEHrzXc7N+63/CtQrPyCL9DdYOBGMihUrFnIH+yEoK3mgmCmWy5eWI+qxpaWBZzCl BLlQPwePmXljMDTQnwvsbF6EE3lToQjQ7Iccl2BuNbYr9nWVj3FjEK5sP5vpCgm+u/JA OmgfkTzuoRkROks3v1ogRJW+92of0BKF/LhaKsKNBQ2uL1w7zUZkcJw06hR/4JZwK6Yh ifut3s3dDgEGYUwi/QEbHgLyoeHihvPF0d6QqUWcuYazXhaKRryIzK7qdHjOZ0m6IemR D6AxPeszFizZUaMCbyl6EJzGJaw7VPG5s+6V3qPS8mw0HnC1obiLDcjfLfQaMwwI+rao KX1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=+Jk6vQ2/y62O3wDV36pIVc4EkqWLq/+WqY6aizMxLxs=; b=FLMcuuI9GU49o9bwuTYObh7IY0cDk+iPBUBmg0FBROL9WBhbdQt+13ZVnMivJDUdiL GCrD3CQX4bkl4UPnk0LsOEfB1Pj/tSDPkC4h8myO0jvQjnHolPvVR90H6Km7r5QYcEXX 3tsVhO/RNkwZn+B5Q7zSIskeRQx8mDnSqYWDRXfRrX3HOi22+W92eDPetWqKGPSDyLBY nlEJK1rDQLW0KWE2J/B149elt6hrfLBZ2/sYdlhAZ6aGA081c/mdvmTed7EFpMCrXGI3 o29Mk9JXIm8V1Sdz8xdsI00rfS8uUfg7i2lA9TpNX0N/WIR39xIzJ1U+rQVEGZvtEY+O SYjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ta2Fz/+P; 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 f20-v6si13378548pgn.464.2018.05.30.19.37.26; Wed, 30 May 2018 19:37:51 -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=Ta2Fz/+P; 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 S932643AbeEaCer (ORCPT + 99 others); Wed, 30 May 2018 22:34:47 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:44275 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932602AbeEaCep (ORCPT ); Wed, 30 May 2018 22:34:45 -0400 Received: by mail-oi0-f66.google.com with SMTP id c128-v6so8949494oig.11 for ; Wed, 30 May 2018 19:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+Jk6vQ2/y62O3wDV36pIVc4EkqWLq/+WqY6aizMxLxs=; b=Ta2Fz/+PIg1JDKgLZFdHr6TLsyyfKWqDlHMkAyJADtqwq2eQzSdSFwGzlhIt5OyY3J S70hbT04aoH3Z1jhQPV4ELjjTqBsjPoBvWllREgkRgsrLDG3z2Dq+olmYiPK1GLygryk 0xsPln/ianyiLBTkJFBQ307Owiqh7o3+NQ2GE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+Jk6vQ2/y62O3wDV36pIVc4EkqWLq/+WqY6aizMxLxs=; b=mPpt0PrKmTcMsXZjEeq/WcYExy04fk+f2yG7W6CUNZ5vici/oWOZKQCpOF6LUvnfIo vyh94q0MhtH7yj/lko5Ee9RfA4Xl+gmEIk1l88tht8tqyR8LqxYi6R+ukdyxjGOJGr3l AxLk+9yaMVIp0j1qJRAIp6IYZ/WdVxQV9u80O14tKRlmAbBVo2Mqh/LucT2X3eBbyzaq WwPuQBbbvMQyCo/qYUfYCSdOngHN77JOPLwJ95IIoRbZOr9tSZGWIB85MSBoNESpQ2Jv 4fatEMv29yGb3XsX+N460MHC38pZc3cyAY2Sji3NEegGPGhz5tFfIy8JQhY/DQD4j13u +MIA== X-Gm-Message-State: ALKqPwerD+uca6EzxptX1vdBqgcO0NeS2sJJYM+NrGTSRVGzcvcLmKr6 Od2yQobpDhGc+vkDM4zhlSoPz3jokEol/FnHFUSnK8BJCPA= X-Received: by 2002:aca:acd7:: with SMTP id v206-v6mr3025234oie.320.1527734084872; Wed, 30 May 2018 19:34:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2d44:0:0:0:0:0 with HTTP; Wed, 30 May 2018 19:34:44 -0700 (PDT) In-Reply-To: <20180530154110.GA22184@bombadil.infradead.org> References: <59623b15001e5a20ac32b1a393db88722be2e718.1527679621.git.baolin.wang@linaro.org> <20180530120133.GC17450@bombadil.infradead.org> <20180530151327.GA13951@bombadil.infradead.org> <20180530154110.GA22184@bombadil.infradead.org> From: Baolin Wang Date: Thu, 31 May 2018 10:34:44 +0800 Message-ID: Subject: Re: [PATCH] mm: dmapool: Check the dma pool name To: Matthew Wilcox Cc: linux-mm@kvack.org, LKML , Arnd Bergmann , Mark Brown Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30 May 2018 at 23:41, Matthew Wilcox wrote: > On Wed, May 30, 2018 at 08:13:27AM -0700, Matthew Wilcox wrote: >> On Wed, May 30, 2018 at 08:14:09PM +0800, Baolin Wang wrote: >> > On 30 May 2018 at 20:01, Matthew Wilcox wrote: >> > > On Wed, May 30, 2018 at 07:28:43PM +0800, Baolin Wang wrote: >> > >> 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. >> > > >> > > NAK. Crashing is the appropriate thing to do. Fix the caller to not >> > > pass NULL. >> > > >> > > If you permit NULL to be passed then you're inviting crashes or just >> > > bad reporting later when pool->name is printed. >> > >> > I think it just prints one NULL pool name. Sometimes the device >> > doesn't care the dma pool names, so I think we can make code more >> > solid to valid the passing parameters like other code does. >> > Or can we add check to return NULL when the passing name is NULL >> > instead of crashing the kernel? Thanks. >> >> No. Fix your driver. > > Let me elaborate on this. Kernel code is supposed to be "reasonable". > That means we don't check every argument to every function for sanity, > unless it's going to cause trouble later. Crashing immediately with > a bogus argument is fine; you can see the problem and fix it immediately. > Returning NULL with a bad argument is actually worse; you won't know why > the function returned NULL (maybe we're out of memory?) and you'll have > a more complex debugging experience. > > Sometimes it makes sense to accept a NULL pointer and do something > reasonable, like kfree(). In this case, we can eliminate checks in all > the callers. But we don't, in general, put sanity checks on arguments > without a good reason. > > Your reasons aren't good. "The driver doesn't care" -- well, just pass > the driver's name, then. Thanks for your explanation. OK, force the driver to pass a pool name. Sorry for noises. -- Baolin.wang Best Regards