Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp844886ybi; Fri, 12 Jul 2019 05:35:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2AZVTxLpxbHz0BTCmG7Yq740drdXuuJ3ta2WgIOgc9qj0DyqaMVf9JuaRXziFQM1coM2o X-Received: by 2002:a17:902:aa83:: with SMTP id d3mr10943259plr.74.1562934956529; Fri, 12 Jul 2019 05:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934956; cv=none; d=google.com; s=arc-20160816; b=X19EbRJ+XtGxTCpRBEa3rqW6bhFpah5x2Kd/sA7xsmiUqMcvwVUPjc3aYO3o9FlZIw Ln+f4OHAbh8dA217ShWKEpvn0N8Vi4XrylXHU6Sr4JWQNcdqZxC704wuyYx+eFx+vOuY iKo7e6wCIpjPdHLbbM3qLTyeXjNlnUlEeWSgeKzcCEokSUOZKWHO8f2lgGhOwVUaHOvK Pt6sNTehZG+9vdMINn7hBiJmpuh6qY/mIvEayEa49pJLHoxjgBcJSp77UyXjoosXJGAH 1Gw1oeK0jzHLxLpOIl+3j6mtkLIgkRd+vlSE84ZeBnpH1RzwmNSWYPTaVKgYp7s5m0zq XsIQ== 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=dBd8xzZXnoeouZw7CLwO6EzBIWbLEOJi+jzKFNRJRJU=; b=KmBNk7WY4JAbLW30gp7a00V6z2pDJF6qLoQ2z1EUuUwZH3EY/LSqj8wEq8+Yu3SQ58 wtX0uR2xAHLmN/6VOxe7x42ivx0DJ1LnIJJCH2FghkCR53w2avKn9k2hs5pQGTQbBLDt kioorJqvUeuysJUPpNak1rOSWKuypnBunHs8sX2un4bE2TYlfx4gFtdHV6QceyzHtq0N ltgfIfRX0JU6kt4KqnlltCfBGX1dAyh5hv249aa2o0zYy/YX3Bw1Yos2pFh/bBeYDo3S jfmjyxb4Vs2tbtbFTWi2d5byVTWY/fIE0NV7H+n2jGQIDz7YYqb4emKaYesn9opvk0ar c6bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="U/XjRu3B"; 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 4si422868pfg.55.2019.07.12.05.35.41; Fri, 12 Jul 2019 05:35:56 -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="U/XjRu3B"; 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 S1729145AbfGLMd2 (ORCPT + 99 others); Fri, 12 Jul 2019 08:33:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:52572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729208AbfGLMdZ (ORCPT ); Fri, 12 Jul 2019 08:33:25 -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 458DF216C4; Fri, 12 Jul 2019 12:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934804; bh=t5280lZFvII97lEhHEy/0FVCtgfXs0UW8Pa4O96y/hI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/XjRu3BhRa+eGL0FBQaUUekgzX61sWlJVHhLGKoANuamW78mL9jpkbZwp7K6ZjpA fqTWDV/9ejFDKZofR9CpGxcAOHcH6yJoX0e2eQW8vmRFuTjTVRomglsYSO/Jq6mhT/ EE5mXEwHdIh2YUjQlak0TyRHBqHXjGJ9l6JbZLC8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.2 35/61] staging: comedi: dt282x: fix a null pointer deref on interrupt Date: Fri, 12 Jul 2019 14:19:48 +0200 Message-Id: <20190712121622.493069211@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121620.632595223@linuxfoundation.org> References: <20190712121620.632595223@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 b8336be66dec06bef518030a0df9847122053ec5 upstream. The interrupt handler `dt282x_interrupt()` causes a null pointer dereference for those supported boards that have no analog output support. For these boards, `dev->write_subdev` will be `NULL` and therefore the `s_ao` subdevice pointer variable will be `NULL`. In that case, the following call near the end of the interrupt handler results in a null pointer dereference: comedi_handle_events(dev, s_ao); Fix it by only calling the above function if `s_ao` is valid. (There are other uses of `s_ao` by the interrupt handler that may or may not be reached depending on values of hardware registers. Trust that they are reliable for now.) Note: commit 4f6f009b204f ("staging: comedi: dt282x: use comedi_handle_events()") propagates an earlier error from commit f21c74fa4cfe ("staging: comedi: dt282x: use cfc_handle_events()"). Fixes: 4f6f009b204f ("staging: comedi: dt282x: use comedi_handle_events()") Cc: # v3.19+ Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -557,7 +557,8 @@ static irqreturn_t dt282x_interrupt(int } #endif comedi_handle_events(dev, s); - comedi_handle_events(dev, s_ao); + if (s_ao) + comedi_handle_events(dev, s_ao); return IRQ_RETVAL(handled); }