From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bl2nam02on0134.outbound.protection.outlook.com ([104.47.38.134]:26720 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032618AbeCAPjj (ORCPT ); Thu, 1 Mar 2018 10:39:39 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Stefan Windfeldt-Prytz , Jonathan Cameron , Sasha Levin Subject: [added to the 4.1 stable tree] iio: buffer: check if a buffer has been set up when poll is called Date: Thu, 1 Mar 2018 15:27:54 +0000 Message-ID: <20180301152116.1486-508-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Stefan Windfeldt-Prytz This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 4cd140bda6494543f1c1b0ccceceaa44b676eef6 ] If no iio buffer has been set up and poll is called return 0. Without this check there will be a null pointer dereference when calling poll on a iio driver without an iio buffer. Cc: stable@vger.kernel.org Signed-off-by: Stefan Windfeldt-Prytz Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/industrialio-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-b= uffer.c index 7fa280b28ecb..ec6b26f008d9 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -150,7 +150,7 @@ unsigned int iio_buffer_poll(struct file *filp, struct iio_dev *indio_dev =3D filp->private_data; struct iio_buffer *rb =3D indio_dev->buffer; =20 - if (!indio_dev->info) + if (!indio_dev->info || rb =3D=3D NULL) return 0; =20 poll_wait(filp, &rb->pollq, wait); --=20 2.14.1