Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2244487imm; Thu, 7 Jun 2018 07:37:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJoy0yiMeCrlbuXoDnzKw+gPV2a91Vyn77D1AFpAiyZ13YPmtT7Q85b4P87i38knVoD7YjH X-Received: by 2002:a17:902:7d8e:: with SMTP id a14-v6mr2342943plm.218.1528382239546; Thu, 07 Jun 2018 07:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382239; cv=none; d=google.com; s=arc-20160816; b=Eply2YSWFGqVeDQj5saud1QsKFe9RMPRRE6e23TFmzyCJrU3xiDl78szj94MmPMmKb fvsTUUIsU+TmNhBpRbHpgKrSPe8NDkjKqB6cX2rKlnzRHFZB7fQiVMK+GZkMO8R0AYpX +TmnbtsXyKChgQP0j+97ybj7z1zXNJKfmWLW3+/baMEUowA3DFk+T7bpCCmqFIK6BIua 13JOTQSjQ9Fkimwmw7BUJt7xgWFWsSqlaca6hKxHpZU+0PcwW383bJ+lN4OUbBx0CM1j vNeUeYntDgt16FBNx4nubT5/7zzH6CSG7XslliJtV82WvIiwLUYsBckli8vXF4Izn9+p rLuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=PGabyBlP/0l3ivOzy/WsljSMyInF1eCMyN1WPq8AAgA=; b=GeNeo4B+nLIrLDozD89Enkv/iIpO8s46jpXjBoDkZoIi9umLH9p8aA+BnRne9C6H9b AZ3LyIqpmPt4oCoGG+W8BXdDF7c5zEQgtpvjk7F87LLp40RZkje0swtjMbUEaM/47adQ hKQ12BBYJu+K/FfnOBi5lZD8vFiwm+zdFXGyBKEWRHKl2pXucascFnIuBqbtusjanLQb oTyqKh6jrsCgnIl0/Oz8B48GNhleW12wW42G4HbZ7C3UgB+mgguUDpYyxp1BTBelW3q5 yCvQC7Z3LAG+r8Mg9Jg1oPVL7HDEVb8uYvYHLd6u7hNOvasUIilQOk+v+oGlWH5LrBWb iuJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 31-v6si54097247plz.364.2018.06.07.07.37.05; Thu, 07 Jun 2018 07:37:19 -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; 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 S934008AbeFGOe4 (ORCPT + 99 others); Thu, 7 Jun 2018 10:34:56 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40365 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933302AbeFGOev (ORCPT ); Thu, 7 Jun 2018 10:34:51 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvba-0005dI-K7; Thu, 07 Jun 2018 15:09:34 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb8-00035T-MA; Thu, 07 Jun 2018 15:09:06 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Stefan Windfeldt-Prytz" , "Jonathan Cameron" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 260/410] iio: buffer: check if a buffer has been set up when poll is called In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Windfeldt-Prytz commit 4cd140bda6494543f1c1b0ccceceaa44b676eef6 upstream. 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. Signed-off-by: Stefan Windfeldt-Prytz Signed-off-by: Jonathan Cameron Signed-off-by: Ben Hutchings --- drivers/iio/industrialio-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -95,7 +95,7 @@ unsigned int iio_buffer_poll(struct file struct iio_dev *indio_dev = filp->private_data; struct iio_buffer *rb = indio_dev->buffer; - if (!indio_dev->info) + if (!indio_dev->info || rb == NULL) return 0; poll_wait(filp, &rb->pollq, wait);