From patchwork Sat Dec 18 22:33:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 76101 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4729BB7093 for ; Sun, 19 Dec 2010 09:43:29 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752779Ab0LRWnI (ORCPT ); Sat, 18 Dec 2010 17:43:08 -0500 Received: from swampdragon.chaosbits.net ([90.184.90.115]:17193 "EHLO swampdragon.chaosbits.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559Ab0LRWnG (ORCPT ); Sat, 18 Dec 2010 17:43:06 -0500 Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id 037CB9403D; Sat, 18 Dec 2010 23:33:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 0115C9403B; Sat, 18 Dec 2010 23:33:40 +0100 (CET) Date: Sat, 18 Dec 2010 23:33:40 +0100 (CET) From: Jesper Juhl To: Karsten Keil cc: "David S. Miller" , Julia Lawall , Tejun Heo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Eversberg Subject: [PATCH] ISDN cmx: Avoid potential NULL deref in dsp_cmx_send_member() and shrink code size. Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi there, In drivers/isdn/mISDN/dsp_cmx.c::dsp_cmx_send_member() we currently have this code: if (dsp->conf && dsp->conf->software && dsp->conf->hardware) tx_data_only = 1; if (dsp->conf->software && dsp->echo.hardware) tx_data_only = 1; The first line implies that 'dsp->conf' may be NULL. If it is, then the third line will dereference a NULL pointer. This patch reworks the code so that we avoid the potential NULL deref. It also has the added benefit that the object file size shrinks a bit. before: text data bss dec hex filename 18840 112 5784 24736 60a0 drivers/isdn/mISDN/dsp_cmx.o after: text data bss dec hex filename 18816 112 5776 24704 6080 drivers/isdn/mISDN/dsp_cmx.o Signed-off-by: Jesper Juhl --- dsp_cmx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) compile tested only diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c index 76d9e67..f76f595 100644 --- a/drivers/isdn/mISDN/dsp_cmx.c +++ b/drivers/isdn/mISDN/dsp_cmx.c @@ -1326,10 +1326,9 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) dsp->last_tx = 0; return; } - if (dsp->conf && dsp->conf->software && dsp->conf->hardware) - tx_data_only = 1; - if (dsp->conf->software && dsp->echo.hardware) - tx_data_only = 1; + if (dsp->conf && dsp->conf->software) + if (dsp->conf->hardware || dsp->echo.hardware) + tx_data_only = 1; } #ifdef CMX_DEBUG