Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp851796ybi; Fri, 12 Jul 2019 05:42:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG5qVhurvQF9VEPZgPQM8sbwfreAgumPTtk+EzZzmR7x6p6MS3yZEpyDkEADIUcxY6P0Wx X-Received: by 2002:a17:90a:1ac5:: with SMTP id p63mr11346853pjp.25.1562935378743; Fri, 12 Jul 2019 05:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935378; cv=none; d=google.com; s=arc-20160816; b=0pkiWUwbhMrYeU0bAfIEGEY52/Pm2E77TAf5UYjcuTsKRp9l8Fu7QQM19hzJyih3ol VG9ORZF4EEoTniogusiAn3JG6qPomhjeeBaqUq/qj6+ttO24vG3g37zxIlpvI3J6eDn2 EpnaQsMtnQQg6KPu5uL9ZGoH2hc6GZPD9jziJzw/Y5Kv6uaCjMwiH+dXlcVxG/OOoSCW hkkYKk5yhaoUj6IaKVltOLkHUwv2Tgjnki3AfKvrilD9a16Qu55b1OCf7gq60TIoktWM XSvuLNztyUjnrDRgmusxSEEFFv9FEWAcGSit/zDymYGJyGJU1g5XZjSjeVlLQOe0buxb MjBA== 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=oiIxvkT0s80i+aTLgCSWifbrG2ZPXN7EKEYZC1bXHLpfoV49aVPYavOcX7fr+RF2hP HBAnbu0WoKNtd3pgQDLEkIoL2dWEHL7OCpolTqk6vUzcKhbCp24DEe1uc6y5yLwoQapw jaIr/qmCYo+h8i9mDSS2/2O8766m1vQYBkheDWznP9AhgnMmzGTMMRbWz0I486DD4Bkt iv7GbYBv4WXD0LfF7Ams+9MSQrOyHS2a8I2xR4LdllUfPdPhneRSqLIda6fdbvkhoxQO LmnqO2Xl9slY/nmygn/kqXcCHVJDrRFIO9B8kCUEtQRODlB2QHm53jJqZFLjDLL5DE7h ZGxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R83u+4c+; 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 78si7863149pga.411.2019.07.12.05.42.43; Fri, 12 Jul 2019 05:42:58 -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=R83u+4c+; 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 S1727535AbfGLMYC (ORCPT + 99 others); Fri, 12 Jul 2019 08:24:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:59968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727991AbfGLMXv (ORCPT ); Fri, 12 Jul 2019 08:23:51 -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 81D2A216E3; Fri, 12 Jul 2019 12:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934231; bh=t5280lZFvII97lEhHEy/0FVCtgfXs0UW8Pa4O96y/hI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R83u+4c+KrbQk0CCS3rCU18V3LAD3UVTtQb6I6nEnPYpcArFIVqAF4jwV8OmfpqD5 iikatL381LlJaPz3cwTIrVJ7UaXrx7/i2r9WPyCYgCAf+rdAKl4AqJDZOQbWpNK1rZ 7gDsPn4MddU5uypHQFJUyOqZp1PdN4ixQogDO3Z8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 4.19 78/91] staging: comedi: dt282x: fix a null pointer deref on interrupt Date: Fri, 12 Jul 2019 14:19:21 +0200 Message-Id: <20190712121625.991361986@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 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); }