From patchwork Mon Oct 8 12:35:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1565341 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 81CB340135 for ; Mon, 8 Oct 2012 12:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037Ab2JHMf6 (ORCPT ); Mon, 8 Oct 2012 08:35:58 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:51246 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810Ab2JHMf5 (ORCPT ); Mon, 8 Oct 2012 08:35:57 -0400 Received: by mail-qa0-f46.google.com with SMTP id c26so2027391qad.19 for ; Mon, 08 Oct 2012 05:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=glvbBCkA3Z4XMcp5/9JZ9vfkqnIU+emTGstrla3vh4U=; b=lQnSBatdToqMMAZZdbCoHSm578+BOx4hiczrlVn8lM80/Gp4CJL5FJghyZcRu5SZ46 OYD/c4Onm9tKUwpMFGn2zR9Q2qRAQgb5m0csU6RM3jVaIGEN2uoUixxeLsN4eMaoGMEV gGupIE1kF6Ng73Uf7zMtZ8jrvBu9n+MUrfz4OnFpL/Ev/uvWCX9C41pnEJb2GDw4iE13 qsEYzcqenPyfZgf8p/mMiQnFf6F0g5WrSvdmokWR6VT8cZY/Miq8z/PLz+himZbEbcWW gF7NsEXGbmNugJ0hnKx8hiGHwYAXQTAcDiyh7pjIaxlfSWHE2bQGYWH6e6LQV63SiJA6 DrMw== MIME-Version: 1.0 Received: by 10.224.178.4 with SMTP id bk4mr11655935qab.38.1349699756896; Mon, 08 Oct 2012 05:35:56 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Mon, 8 Oct 2012 05:35:56 -0700 (PDT) Date: Mon, 8 Oct 2012 20:35:56 +0800 Message-ID: Subject: [PATCH] dvb-frontends: fix potential NULL pointer dereference in stv0900_set_mclk() From: Wei Yongjun To: mchehab@infradead.org Cc: yongjun_wei@trendmicro.com.cn, linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Wei Yongjun The dereference should be moved below the NULL test. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun --- drivers/media/dvb-frontends/stv0900_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c index 7f1bada..274a71c 100644 --- a/drivers/media/dvb-frontends/stv0900_core.c +++ b/drivers/media/dvb-frontends/stv0900_core.c @@ -300,15 +300,15 @@ static enum fe_stv0900_error stv0900_set_mclk(struct stv0900_internal *intp, u32 { u32 m_div, clk_sel; - dprintk("%s: Mclk set to %d, Quartz = %d\n", __func__, mclk, - intp->quartz); - if (intp == NULL) return STV0900_INVALID_HANDLE; if (intp->errs) return STV0900_I2C_ERROR; + dprintk("%s: Mclk set to %d, Quartz = %d\n", __func__, mclk, + intp->quartz); + clk_sel = ((stv0900_get_bits(intp, F0900_SELX1RATIO) == 1) ? 4 : 6); m_div = ((clk_sel * mclk) / intp->quartz) - 1; stv0900_write_bits(intp, F0900_M_DIV, m_div);