From patchwork Fri Sep 25 07:56:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abylai Ospan X-Patchwork-Id: 7262851 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 EFC1C9F6CD for ; Fri, 25 Sep 2015 07:56:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2805320B5F for ; Fri, 25 Sep 2015 07:56:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45F8320B42 for ; Fri, 25 Sep 2015 07:56:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754894AbbIYH40 (ORCPT ); Fri, 25 Sep 2015 03:56:26 -0400 Received: from team.netup.ru ([77.72.80.1]:34184 "EHLO a-desktop" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753442AbbIYH4Z (ORCPT ); Fri, 25 Sep 2015 03:56:25 -0400 Received: by a-desktop (Postfix, from userid 1001) id 192C92E26AE; Fri, 25 Sep 2015 03:56:23 -0400 (EDT) From: Abylay Ospan To: linux-media@vger.kernel.org, serjk@netup.ru, aospan@netup.ru, dan.carpenter@oracle.com, m.chehab@samsung.com Subject: [PATCH] [media] netup_unidvb: fix potential crash when spi is NULL Date: Fri, 25 Sep 2015 03:56:21 -0400 Message-Id: <1443167781-23220-1-git-send-email-aospan@netup.ru> X-Mailer: git-send-email 2.1.4 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, RCVD_IN_DNSWL_HI, 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 Signed-off-by: Abylay Ospan Reported-by: Dan Carpenter --- drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c index f55b327..56773f3 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c @@ -80,11 +80,9 @@ irqreturn_t netup_spi_interrupt(struct netup_spi *spi) u16 reg; unsigned long flags; - if (!spi) { - dev_dbg(&spi->master->dev, - "%s(): SPI not initialized\n", __func__); + if (!spi) return IRQ_NONE; - } + spin_lock_irqsave(&spi->lock, flags); reg = readw(&spi->regs->control_stat); if (!(reg & NETUP_SPI_CTRL_IRQ)) { @@ -234,11 +232,9 @@ void netup_spi_release(struct netup_unidvb_dev *ndev) unsigned long flags; struct netup_spi *spi = ndev->spi; - if (!spi) { - dev_dbg(&spi->master->dev, - "%s(): SPI not initialized\n", __func__); + if (!spi) return; - } + spin_lock_irqsave(&spi->lock, flags); reg = readw(&spi->regs->control_stat); writew(reg | NETUP_SPI_CTRL_IRQ, &spi->regs->control_stat);