From patchwork Fri Aug 12 03:33:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Manna X-Patchwork-Id: 1059562 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7C3Y4i7018539 for ; Fri, 12 Aug 2011 03:34:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752890Ab1HLDeC (ORCPT ); Thu, 11 Aug 2011 23:34:02 -0400 Received: from caiajhbdcbef.dreamhost.com ([208.97.132.145]:58504 "EHLO homiemail-a63.g.dreamhost.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751307Ab1HLDeB (ORCPT ); Thu, 11 Aug 2011 23:34:01 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Aug 2011 03:34:07 +0000 (UTC) X-Greylist: delayed 86762 seconds by postgrey-1.27 at vger.kernel.org; Thu, 11 Aug 2011 23:34:00 EDT Received: from homiemail-a63.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a63.g.dreamhost.com (Postfix) with ESMTP id 2160D2F4057; Thu, 11 Aug 2011 20:34:00 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=kylemanna.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; q=dns; s= kylemanna.com; b=rkU5QvHmNQq2e6uW5NEt0XDXzbcOrDf4qXyKrdRs7n8rLfo J7WrzmCMUZ4kzU+Z1/TP4qIlAVHbeFZrPFPdKs0qrz81Hq+VZZhbxhItYGQYHMEf 2PVwxgYRMOiuO+0dGFfEzBYqe+dyRRxAxkJ4vnu/5Uv+lpZd3rzDIK6dLeOU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=kylemanna.com; h=from:to :cc:subject:date:message-id:in-reply-to:references; s= kylemanna.com; bh=exN9RyDT4mCL1HbMZxrt2QC05As=; b=Rtn7+VVy47rcjl x0pIW1SI+R6NZM3RcceGCkhVtoYRSxpvO+JskY81ZeLMWF5ECnYYGHw/+1ckoFqR sz1PHI4F1omW+eMf8RVkzit+XaNjtcu5RXoK0cQkfQIDowroKH9jaxW5lm9fRk9X C3njKVhgZiK2RDc4gkQSI5WTeyY0c= Received: from core (cpe-70-116-138-43.tx.res.rr.com [70.116.138.43]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: core@frozenliquid.net) by homiemail-a63.g.dreamhost.com (Postfix) with ESMTPSA id 046732F4056; Thu, 11 Aug 2011 20:34:00 -0700 (PDT) Received: by core (Postfix, from userid 1000) id 2EE3668217F; Thu, 11 Aug 2011 22:33:59 -0500 (CDT) From: Kyle Manna To: Tony Lindgren , Russell King , Samuel Ortiz Cc: Keerthy , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kyle Manna Subject: [PATCH v2 3/4] mfd: twl4030-madc: check for NULL pointer Date: Thu, 11 Aug 2011 22:33:14 -0500 Message-Id: <1313119995-15382-4-git-send-email-kyle@kylemanna.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1313119995-15382-1-git-send-email-kyle@kylemanna.com> References: <1313119995-15382-1-git-send-email-kyle@kylemanna.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org If the twl4030-madc device wasn't registered, and another device, such as twl4030-madc-hwmon, calls twl4030_madc_conversion() a NULL pointer is dereferenced. Signed-off-by: Kyle Manna --- drivers/mfd/twl4030-madc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c index 99dd611..834f824 100644 --- a/drivers/mfd/twl4030-madc.c +++ b/drivers/mfd/twl4030-madc.c @@ -510,8 +510,9 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req) u8 ch_msb, ch_lsb; int ret; - if (!req) + if (!req || !twl4030_madc) return -EINVAL; + mutex_lock(&twl4030_madc->lock); if (req->method < TWL4030_MADC_RT || req->method > TWL4030_MADC_SW2) { ret = -EINVAL;