Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp833729ybi; Fri, 12 Jul 2019 05:25:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwda7Kn/g2zUGETBbGVyDOFApX4fwnsz+j5mtth+F7hqXlpAokvk8bqYIGh7HJU7r4QVcnI X-Received: by 2002:a65:42c3:: with SMTP id l3mr10508009pgp.372.1562934314459; Fri, 12 Jul 2019 05:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934314; cv=none; d=google.com; s=arc-20160816; b=0O1kwPG1fHT/kWIm1P6pCphmp2GaYWE2MTdvYcelhBvqHVIivRGGV34eqs4q+Xka7u F1ifbeOQxNajRogBfKVjzxG4J0wDbAtr247xI29I5Tio3gAwZ+e+GAf21fSu6b3h5N5M ZI5P5QPLjrcIqRXcLacHgyZ/HsEDs0TObxlEsCmggk+dYv2ZmqgzR9MBonmWDefiivJ9 MOMUcQqpzuHmXGI6yqz/B62u2HRCdjs99PSf320CRr6IfC3SOQpEMmFlw54Pg4HF8QGk ulIX1vmaPtxEncJZkGbP7ZhKwQSVCXFCyoJi+iQ59Gz2RR9U+1icf+ti98OrsvNv3Ht2 BCWQ== 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=Y7x7uxjUaSndyjeZzy5reG4vLVHvFYPnTidz8jazlfQ=; b=I9Ldc4n2+QaANUL5HYxexZxhiloOIitHh67graO2pdrpPRSUBS2MUvI0j1SJEuBIfp 5zptqu13WogzErSefrrHLeSb6o/cB3NvTQoX8GFv1b5xGhfHM920Ki3Lo34OpIzRxZA/ uxnl0TSsuMD84VakxdslXW/kPSdrqXh5bhD+fJ6Z1r5jD5uU4JzVMWYklrifcp2+jI9T 9CBZTWDfQNA1BVUUC6m9i79KUOUg7ZD3AKZBuu6C5PgkmQH5RibwCnrMuffwnHJ1TIRp ZwWJiRrbJtcGF5/mwodQbUcAsX/Lf35VHo4W9zJNbCXPVzJQkZv/GKGMghsZB6xT7vnG 8zfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CUQwncYp; 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 t6si2432977pgu.154.2019.07.12.05.24.59; Fri, 12 Jul 2019 05:25:14 -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=@kernel.org header.s=default header.b=CUQwncYp; 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 S1727530AbfGLMYG (ORCPT + 99 others); Fri, 12 Jul 2019 08:24:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:60060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727980AbfGLMXz (ORCPT ); Fri, 12 Jul 2019 08:23:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A73122166E; Fri, 12 Jul 2019 12:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934234; bh=vaXuefLnQVX1WIZfUStZejGF9m9Z62dsxQs1bUacwK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CUQwncYpbZwDQFDUQK+yfVKx9FuqGlp/uOidx6/jNTw2n0ualSHts9AzmNfzdBPtI h09AfRfZq0Ys0y4ZMPVfEhRKj3FZPVtUR8KqOOU+J3FMHN0V/p1K55EZBn+gFILw0r d2mInNu7c+GkhmQmBzGH0mAJuVKKjb6oi/163nBs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 4.19 79/91] staging: comedi: amplc_pci230: fix null pointer deref on interrupt Date: Fri, 12 Jul 2019 14:19:22 +0200 Message-Id: <20190712121626.037573937@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121621.422224300@linuxfoundation.org> References: <20190712121621.422224300@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 7379e6baeddf580d01feca650ec1ad508b6ea8ee upstream. The interrupt handler `pci230_interrupt()` causes a null pointer dereference for a PCI260 card. There is no analog output subdevice for a PCI260. The `dev->write_subdev` subdevice pointer and therefore the `s_ao` subdevice pointer variable will be `NULL` for a PCI260. The following call near the end of the interrupt handler results in the null pointer dereference for a PCI260: comedi_handle_events(dev, s_ao); Fix it by only calling the above function if `s_ao` is valid. Note that the other uses of `s_ao` in the calls `pci230_handle_ao_nofifo(dev, s_ao);` and `pci230_handle_ao_fifo(dev, s_ao);` will never be reached for a PCI260, so they are safe. Fixes: 39064f23284c ("staging: comedi: amplc_pci230: use comedi_handle_events()") Cc: # v3.19+ Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2330,7 +2330,8 @@ static irqreturn_t pci230_interrupt(int devpriv->intr_running = false; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); - comedi_handle_events(dev, s_ao); + if (s_ao) + comedi_handle_events(dev, s_ao); comedi_handle_events(dev, s_ai); return IRQ_HANDLED;