Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4831854ybl; Wed, 22 Jan 2020 05:33:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxD4HPu6DDKdVi2JbLvk2LcFV00hPCSoYDfjn6vZweLxDx9YKppa8r3rWlLCXyIXvJYMi7V X-Received: by 2002:a9d:7410:: with SMTP id n16mr7652574otk.23.1579700016678; Wed, 22 Jan 2020 05:33:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579700016; cv=none; d=google.com; s=arc-20160816; b=ZHt0/sn6d/zsQ9EbHCBn5Gl2laBj51qFTta2ZMMxqHBwuHJtq6A0HqHiByxxpiDzfa 5gzrhuYWptJlaalvbujkYLo/XHmvELJ7YksDyw8fhxpZhOuCSmgFojFdL+XY4ErLeRoc qsI6Yn8/1vLMqR/oyeOo/+/7UmaDWL7xJTiQssX3lwTXaG6e+4FajJQn8tfDbjFskt6A coghktTHcDorwe4QfbdEdOk4JZA/aHvSarsO7bpCAmwEaQ1xhSW54Ln9054vwsveF23u z8PvrA+72lH5u8+rnIlatUSyFCZd1rqdMhU/wyZ6Az5Yyi/G6wicpJ+Vs7sEuhnBWXur KCug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gui2NsnutRW7vvG+Kl+bnCIbDmOT8+wub18qoCUaCP4=; b=CWvjY6mPKVGFHutg98WA6MkqARY6ZOoSmpe73wmFHnJFI2ZNNZyc+gD254HGLo0Nzq FdDcEQ3R5Lv/rStqfyvawQld8zOQuRp0V8kKQrs7nu/AWEu5VKQcPBy57FoHFCdPb3RJ sZPZO1ZWcQwcSmytrJx3Q26AIAhSmXg89SgIdGB8BpZ11YWZ9TW31BHtB2Ryn08JJyBA WWlqTXTOoxbaHahuDWA+QDd9Tyo59YXtT9t8/yPx1SVh5tP4/alXUMi9zjEOTX58mU2Z 2ovxJ5zuoDRl6CUOAbKvNKm3qxmM5Y9HAmbZc0g7PS9I05BpmZEHKyuODtLhlMSvQYyk hLEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WtgG57Zl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si22990708otq.96.2020.01.22.05.33.20; Wed, 22 Jan 2020 05:33:36 -0800 (PST) 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=@kernel.org header.s=default header.b=WtgG57Zl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729568AbgAVNTK (ORCPT + 99 others); Wed, 22 Jan 2020 08:19:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:34902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbgAVNTG (ORCPT ); Wed, 22 Jan 2020 08:19:06 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F1D6C20678; Wed, 22 Jan 2020 13:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699145; bh=sWI9vy28d3cPsQWZHNUBNc/BCrkQ3DbNbsXtE/jxrfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WtgG57ZlhiKZ7oIzAoWnA4Lkc//W+lIMORCQBKgP9CQY0qNKI63n/SVTlvl/7k2pz QZngmZQLsXAsXR+IWF0rD4mC6lFAwvUqMnspWhbf18RfjjUtqXGsLiNpJiz//C4wWe bIUVh97/V8J8eraQn+y7gCyQhaHz9yG4fyxuugSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Spencer E. Olson" , Ian Abbott Subject: [PATCH 5.4 054/222] staging: comedi: ni_routes: allow partial routing information Date: Wed, 22 Jan 2020 10:27:20 +0100 Message-Id: <20200122092837.502758644@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Abbott commit 9fea3a40f6b07de977a2783270c8c3bc82544d45 upstream. This patch fixes a regression on setting up asynchronous commands to use external trigger sources when board-specific routing information is missing. `ni_find_device_routes()` (called via `ni_assign_device_routes()`) finds the table of register values for the device family and the set of valid routes for the specific board. If both are found, `tables->route_values` is set to point to the table of register values for the device family and `tables->valid_routes` is set to point to the list of valid routes for the specific board. If either is not found, both `tables->route_values` and `tables->valid_routes` are left set at their initial null values (initialized by `ni_assign_device_routes()`) and the function returns `-ENODATA`. Returning an error results in some routing functionality being disabled. Unfortunately, leaving `table->route_values` set to `NULL` also breaks the setting up of asynchronous commands that are configured to use external trigger sources. Calls to `ni_check_trigger_arg()` or `ni_check_trigger_arg_roffs()` while checking the asynchronous command set-up would result in a null pointer dereference if `table->route_values` is `NULL`. The null pointer dereference is fixed in another patch, but it now results in failure to set up the asynchronous command. That is a regression from the behavior prior to commit 347e244884c3 ("staging: comedi: tio: implement global tio/ctr routing") and commit 56d0b826d39f ("staging: comedi: ni_mio_common: implement new routing for TRIG_EXT"). Change `ni_find_device_routes()` to set `tables->route_values` and/or `tables->valid_routes` to valid information even if the other one can only be set to `NULL` due to missing information. The function will still return an error in that case. This should result in `tables->valid_routes` being valid for all currently supported device families even if the board-specific routing information is missing. That should be enough to fix the regression on setting up asynchronous commands to use external triggers for boards with missing routing information. Fixes: 347e244884c3 ("staging: comedi: tio: implement global tio/ctr routing") Fixes: 56d0b826d39f ("staging: comedi: ni_mio_common: implement new routing for TRIG_EXT"). Cc: # 4.20+ Cc: Spencer E. Olson Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20200114182532.132058-3-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_routes.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/staging/comedi/drivers/ni_routes.c +++ b/drivers/staging/comedi/drivers/ni_routes.c @@ -74,9 +74,6 @@ static int ni_find_device_routes(const c } } - if (!rv) - return -ENODATA; - /* Second, find the set of routes valid for this device. */ for (i = 0; ni_device_routes_list[i]; ++i) { if (memcmp(ni_device_routes_list[i]->device, board_name, @@ -86,12 +83,12 @@ static int ni_find_device_routes(const c } } - if (!dr) - return -ENODATA; - tables->route_values = rv; tables->valid_routes = dr; + if (!rv || !dr) + return -ENODATA; + return 0; }