From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66BDCC433E2 for ; Tue, 15 Sep 2020 22:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37DF220795 for ; Tue, 15 Sep 2020 22:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbgIOPwk (ORCPT ); Tue, 15 Sep 2020 11:52:40 -0400 Received: from verein.lst.de ([213.95.11.211]:48140 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727449AbgIOPJj (ORCPT ); Tue, 15 Sep 2020 11:09:39 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 8D42568AFE; Tue, 15 Sep 2020 17:09:30 +0200 (CEST) Date: Tue, 15 Sep 2020 17:09:29 +0200 From: Christoph Hellwig To: Thomas Tai Cc: Christoph Hellwig , konrad.wilk@oracle.com, m.szyprowski@samsung.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dma-direct: Fix potential NULL pointer dereference Message-ID: <20200915150929.GA19770@lst.de> References: <1600178594-22801-1-git-send-email-thomas.tai@oracle.com> <20200915140719.GA14831@lst.de> <20200915142624.GA16005@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 10:40:39AM -0400, Thomas Tai wrote: >> +++ b/include/linux/dma-direct.h >> @@ -62,9 +62,6 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size, >> { >> dma_addr_t end = addr + size - 1; >> - if (!dev->dma_mask) >> - return false; >> - > > I am concerned that some drivers may rely on this NULL checking. Would you > think we can keep this checking and use the following WARN_ON_ONCE()? dma_capable is not a helper for drivers, but just for dma-direct and related code. And this patch adds the checks for the three places how we call into the ->map* methods.