mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Pavel Mironchik <pmironchik@optifacio.net>
Cc: a.zummo@towertech.it, linux-kernel@vger.kernel.org
Subject: [2.6 patch] drivers/rtc/rtc-rs5c372.c: fix a NULL dereference
Date: Fri, 17 Nov 2006 15:21:59 +0100	[thread overview]
Message-ID: <20061117142159.GY31879@stusta.de> (raw)

The correct order is: NULL check before dereference

This was a guaranteed NULL dereference with debugging enabled since 
rs5c372_sysfs_show_osc() does actually pass NULL...

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.19-rc5-mm2/drivers/rtc/rtc-rs5c372.c.old	2006-11-17 14:15:53.000000000 +0100
+++ linux-2.6.19-rc5-mm2/drivers/rtc/rtc-rs5c372.c	2006-11-17 14:16:53.000000000 +0100
@@ -126,13 +126,13 @@ static int rs5c372_get_trim(struct i2c_c
 		return -EIO;
 	}
 
-	dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
-
 	if (osc)
 		*osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
 
-	if (trim)
+	if (trim) {
 		*trim = buf & RS5C372_TRIM_MASK;
+		dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
+	}
 
 	return 0;
 }


                 reply	other threads:[~2006-11-17 14:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061117142159.GY31879@stusta.de \
    --to=bunk@stusta.de \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmironchik@optifacio.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®