From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Ding Subject: [PATCH] i2c: busses/i2c-pxa.c: fix potential null pointer dereference error Date: Mon, 4 Feb 2013 23:11:36 +0100 Message-ID: <1360015899-13706-1-git-send-email-dinggnu@gmail.com> Return-path: Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Wolfram Sang , Andrew Morton , Karol Lewandowski , Kyungmin Park , Haojian Zhuang , linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Cong Ding List-Id: linux-i2c@vger.kernel.org If it goes to eclk through line 1107, the variable res would be NULL. It will cause a null pointer dereference error if we call release_mem_region. Signed-off-by: Cong Ding --- drivers/i2c/busses/i2c-pxa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 1034d93..eadf1a4 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -1211,7 +1211,8 @@ eremap: eclk: kfree(i2c); emalloc: - release_mem_region(res->start, resource_size(res)); + if (!res) + release_mem_region(res->start, resource_size(res)); return ret; } -- 1.7.9.5