From patchwork Wed Jan 7 01:53:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 5579211 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 147FC9F1C5 for ; Wed, 7 Jan 2015 02:00:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A5BD20251 for ; Wed, 7 Jan 2015 02:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80ABE2010B for ; Wed, 7 Jan 2015 02:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757125AbbAGCAG (ORCPT ); Tue, 6 Jan 2015 21:00:06 -0500 Received: from gw03.mail.saunalahti.fi ([195.197.172.111]:55960 "EHLO gw03.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757108AbbAGCAD (ORCPT ); Tue, 6 Jan 2015 21:00:03 -0500 X-Greylist: delayed 374 seconds by postgrey-1.27 at vger.kernel.org; Tue, 06 Jan 2015 21:00:03 EST Received: from localhost.localdomain (a91-152-110-231.elisa-laajakaista.fi [91.152.110.231]) by gw03.mail.saunalahti.fi (Postfix) with ESMTP id 1327320046; Wed, 7 Jan 2015 03:53:42 +0200 (EET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id t071rflI031846; Wed, 7 Jan 2015 03:53:41 +0200 Received: (from andy@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id t071rcGE031844; Wed, 7 Jan 2015 03:53:39 +0200 X-Authentication-Warning: localhost.localdomain: andy set sender to andy.shevchenko@gmail.com using -f From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH] lirc_dev: avoid potential null-dereference Date: Wed, 7 Jan 2015 03:53:37 +0200 Message-Id: <1420595617-31802-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.8.3.101.g727a46b Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have to check pointer for NULL and then dereference it. Signed-off-by: Andy Shevchenko --- drivers/media/rc/lirc_dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 1e0545a..4de0e85 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -553,14 +553,14 @@ unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait) if (!ir->attached) return POLLERR; - poll_wait(file, &ir->buf->wait_poll, wait); + if (ir->buf) { + poll_wait(file, &ir->buf->wait_poll, wait); - if (ir->buf) if (lirc_buffer_empty(ir->buf)) ret = 0; else ret = POLLIN | POLLRDNORM; - else + } else ret = POLLERR; dev_dbg(ir->d.dev, LOGHEAD "poll result = %d\n",