Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp764092pxb; Tue, 9 Feb 2021 11:46:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkzB3shbTR3l3a2z+D40r0tz1AfPAnJKCjE+Z5+jH/sUvUNy9lfllnIMU93XsKfCYFEcYC X-Received: by 2002:a05:6402:3198:: with SMTP id di24mr24767037edb.340.1612900013088; Tue, 09 Feb 2021 11:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612900013; cv=none; d=google.com; s=arc-20160816; b=eV/a5VO/KFwTzO4UtuItK0HtCmQT07pOlPhkWsguLp3DcT/SABqjFHQ62TLzc3jWlN 8fBQCJ+JNwZBLS3GRfZwHlALvLGs0dvabllf0P7cLm03pfVlZzQ7DjMpwApWGQV1ECDV tUM06CeAJtYlBHY2kyBjfGfUCQnZY2D0yfWVDzZhT5CHggnpot+ncCeIQ7ydNHoFQzk3 pgDbK94B8Zo1bHtT5sfLO/0gbpt3I9uBoSGVg9Bl7uT8IdTdujc4o0vTvxnePL/MYD5R 3baisHnpsf7lN8cSDYx//AIUDE8jBpY56YdT2AyptkTAbiSId3viIjxZsX/74zotLKub 98yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=uLdJv6cZuHRtRFFRIJEOoH3tFE87WZTh9kuO83NwQkA=; b=oCVCBOkW4KtzgswADKZnvy4yFybbIbtI2TeHXG47ldGuB/x9832DiCzjS9+KFjq4YY prZr0vcnlwdAcfrn8Y0/DdzSKiQ5lnyra6S11JqCDaKVYo2dU5z4etV297YJMcl9uZ0T YEWBWDQz5lgmaVmv5fVQVbuzw6lL5w49AQLqEEYbtG0sYx/P7l9jFGG6zvpkO09prEFs addsVxv1vbDsol9/rd9vuazGtZ5mqfPuw2wmp8XIm3wBlhySyZ8IjAxf11PDEKrktvKg 1292TNOZvUXsJlhFDX6j/PM0jY67AHWEessdGMJt/asnWr0+t6kPYZdiTbEx0TrK2VJu GqJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si15798037ejd.572.2021.02.09.11.46.28; Tue, 09 Feb 2021 11:46:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233622AbhBITm6 (ORCPT + 99 others); Tue, 9 Feb 2021 14:42:58 -0500 Received: from mail-wm1-f53.google.com ([209.85.128.53]:52230 "EHLO mail-wm1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233259AbhBISSv (ORCPT ); Tue, 9 Feb 2021 13:18:51 -0500 Received: by mail-wm1-f53.google.com with SMTP id i5so4149045wmq.2; Tue, 09 Feb 2021 10:18:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uLdJv6cZuHRtRFFRIJEOoH3tFE87WZTh9kuO83NwQkA=; b=AQ+XhQOVzY7tNvN+7MromeEYGIc+mQAB+nJkPt0qZSlT3XflLWIVYJS3kuOrlSYnV3 iY8IO7acAMxh4Raaq+esbLoxLLigbJxNsW/qmAnN+jnzRckSF3+HXFAHXwuHa3dk9Afp CQTnAz8ByqxnI5fo1T5NvFB4JT30kM6hGD9s4QJ2PUREIWbZRz8X7Ju4FenHTy3GK3gq 2s0hmen74301TCgW/Tq5aNiher26PN1SqbEaWaYkR6Pc5QJ/X9w/Pa3n6vhupgf7fJzD FtfnBoboDFsGw+lsSF7CO0WnJVZKBjkkmUobv/CaQkUB/QkyGunTZLlNL+Qv4FNoREn+ yt4w== X-Gm-Message-State: AOAM531yJTqrhiAiUo+d6CMDrC4zJIvUeNg8oLZM96SXn4HdyQP7ZUxC wBnMkBZ4UaE4RiHLgXChnP2gO4geLdYcbrS7 X-Received: by 2002:a1c:105:: with SMTP id 5mr4662963wmb.89.1612894688876; Tue, 09 Feb 2021 10:18:08 -0800 (PST) Received: from rocinante ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id u70sm6019208wmu.20.2021.02.09.10.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:18:08 -0800 (PST) Date: Tue, 9 Feb 2021 19:18:06 +0100 From: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= To: Gustavo Pimentel Cc: Bjorn Helgaas , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "dmaengine@vger.kernel.org" , Vinod Koul , Dan Williams , Bjorn Helgaas Subject: Re: [PATCH v4 15/15] dmaengine: dw-edma: Add pcim_iomap_table return checker Message-ID: References: <20210208193516.GA406304@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, [...] > > This "pcim_iomap_table(dev)[n]" pattern is extremely common. There > > are over 100 calls of pcim_iomap_table(), and > > > > $ git grep "pcim_iomap_table(.*)\[.*\]" | wc -l > > > > says about 75 of them are of this form, where we dereference the > > result before testing it. > > That's true, there are a lot of drivers that don't verify that pointer. > What do you suggest? > 1) To remove the verification so that is aligned with the other drivers > 2) Leave it as is. Or even to add this verification to the other drivers? > > Either way, I will add the pcim_iomap_table(pdev) before this > instruction. [...] A lot of the drivers consume the value from pcim_iomap_table() at a given BAR index directly as-is, some check if the pointer they got back is not NULL, a very few also check if the address at a given index is not NULL. Given that the memory allocation for the table can fail, we ought to check for a NULL pointer. It's a bit worrying that people decided to consume the value it returns directly without any verification. I only found two drivers that perform this additional verification of checking whether the address at a given index is valid, as per: https://lore.kernel.org/linux-pci/YCLFTjZQ2bCfGC+J@rocinante/ Personally, I would opt for (2), and then like you suggested send a separate series to update other drivers so that they also include the this NULL pointer check. But let's wait for Bjorn's take on this, though. Krzysztof