From: Dan Carpenter Date: Fri, 07 Sep 2012 06:47:41 +0000 Subject: [patch] HID: picoLCD: fix a NULL test in picolcd_raw_cir() Message-Id: <20120907064740.GB12028@elgon.mountain> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Bruno =?iso-8859-1?Q?Pr=E9mont?= Cc: Jiri Kosina , linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org Smatch complains that the NULL checking in this function is not consistent and could lead to a NULL dereference. The comments say that we should return here if rc_dev is NULL so I've changed the test to match the comment. Signed-off-by: Dan Carpenter --- Only needed in linux-next. This is a static checker fix and I don't have the hardware to test it. Please review carefully. diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c index 14c5ce0..13ca919 100644 --- a/drivers/hid/hid-picolcd_cir.c +++ b/drivers/hid/hid-picolcd_cir.c @@ -51,7 +51,7 @@ int picolcd_raw_cir(struct picolcd_data *data, /* ignore if rc_dev is NULL or status is shunned */ spin_lock_irqsave(&data->lock, flags); - if (data->rc_dev && (data->status & PICOLCD_CIR_SHUN)) { + if (!data->rc_dev || (data->status & PICOLCD_CIR_SHUN)) { spin_unlock_irqrestore(&data->lock, flags); return 1; }