Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6227763pxv; Thu, 29 Jul 2021 09:18:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNeHXwF7QLgj65YyhN84fT+wkdujt770kRyX6S7Iz3438RjJeHssFbKhbpzjOn6+HuUgo1 X-Received: by 2002:a17:906:8248:: with SMTP id f8mr5522971ejx.229.1627575514367; Thu, 29 Jul 2021 09:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627575514; cv=none; d=google.com; s=arc-20160816; b=jxfDLtu/1DTHSXPe8mXtEktWGGuKwgLecAcuomY36hOL8Qlgt1y8+FSatei/D4twev pVUBEexEyAKRGTAurfwrkksxS0Ol3JntPba2VHJGGlRJ87HduKzB0KcUYruqZ3IQj5pe k0Kl4WZFdVSqVSDmxnvfhuETCADf7GPJSQV6F5bFWT/2LVSvWpc+Ns3h4vioUgqjeViI kvopJgbF9MSCUPACyunui95d3js7HyQdfo6oMMmX/nE3wDqc2U3sNR+8ddSMFn3UCJFO QQITugZlwH0x+dIck45S6AYxPn8UmYDPBUDKzIj38+LEs+BDtD51ZdxLfnHKPm26MDdv ycYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=LBkzKvY+mXCjGAfoZWFDT/QWmbec8bUquKz/8ALwVYM=; b=zariymrzk0G4Gg16f3Pcmd7hTEjXBHYfUDwVb9WCDRY0Oi0311SAcCOkBR5F8YSdAx F8vKhROaBoZ2jaTPbYcvDfU07bhWzS5C2PerHF0PXNSNkIWLhGKIcRQhuecIFX4IE3O2 2nI3pdoT8EqhzgbpX4rno5b55xEuRAbeNmnubjmnKTc7nA3Lxxj5dbLHsg5da4mdl4Ub wk+ffCx/cryq9McRnKa2sjb0FKT7ftjA5ZlkN8jKg0sIZadFuQm1T49Yqbm2vyTtgO4B EyiV7sSXzBZu8ZoN5herlqo7q+OyBahTyZJVxytqhq9nyjp9ebBLo5bhtp2wdY0cJG4J wq3w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm29si3107686ejb.380.2021.07.29.09.18.07; Thu, 29 Jul 2021 09:18:34 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbhG2QNl (ORCPT + 99 others); Thu, 29 Jul 2021 12:13:41 -0400 Received: from mga04.intel.com ([192.55.52.120]:42247 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbhG2QNl (ORCPT ); Thu, 29 Jul 2021 12:13:41 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10060"; a="211035522" X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="211035522" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2021 09:12:04 -0700 X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="465130370" Received: from djiang5-mobl1.amr.corp.intel.com (HELO [10.209.170.107]) ([10.209.170.107]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2021 09:12:04 -0700 Subject: Re: [PATCH] dmaengine: idxd: Fix a possible NULL pointer dereference To: Christophe JAILLET , vkoul@kernel.org, dan.j.williams@intel.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <77f0dc4f3966591d1f0cffb614a94085f8895a85.1627560174.git.christophe.jaillet@wanadoo.fr> From: Dave Jiang Message-ID: <44c9607e-2cde-02b9-7e4e-68578a775fb3@intel.com> Date: Thu, 29 Jul 2021 09:12:03 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <77f0dc4f3966591d1f0cffb614a94085f8895a85.1627560174.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/2021 5:04 AM, Christophe JAILLET wrote: > 'device_driver_attach()' dereferences its first argument (i.e. 'alt_drv') > so it must not be NULL. > Simplify the error handling logic about NULL 'alt_drv' in order to be > more robust and future-proof. > > Fixes: 568b2126466f ("dmaengine: idxd: fix uninit var for alt_drv") > Fixes: 6e7f3ee97bbe ("dmaengine: idxd: move dsa_drv support to compatible mode") > > Signed-off-by: Christophe JAILLET Thanks for the cleanup. Acked-by: Dave Jiang > --- > drivers/dma/idxd/compat.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c > index d7616c240dcd..3df21615f888 100644 > --- a/drivers/dma/idxd/compat.c > +++ b/drivers/dma/idxd/compat.c > @@ -45,23 +45,16 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t cou > idxd_dev = confdev_to_idxd_dev(dev); > if (is_idxd_dev(idxd_dev)) { > alt_drv = driver_find("idxd", bus); > - if (!alt_drv) > - return -ENODEV; > } else if (is_idxd_wq_dev(idxd_dev)) { > struct idxd_wq *wq = confdev_to_wq(dev); > > - if (is_idxd_wq_kernel(wq)) { > + if (is_idxd_wq_kernel(wq)) > alt_drv = driver_find("dmaengine", bus); > - if (!alt_drv) > - return -ENODEV; > - } else if (is_idxd_wq_user(wq)) { > + else if (is_idxd_wq_user(wq)) > alt_drv = driver_find("user", bus); > - if (!alt_drv) > - return -ENODEV; > - } else { > - return -ENODEV; > - } > } > + if (!alt_drv) > + return -ENODEV; > > rc = device_driver_attach(alt_drv, dev); > if (rc < 0)