diff mbox

bq2415x_charger: Fix null pointer dereference

Message ID 1442847500-22435-1-git-send-email-pali.rohar@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Pali Rohár Sept. 21, 2015, 2:58 p.m. UTC
Commit b68c3161430a (bq2415x_charger: Allow to load and use driver even if
notify device is not registered yet) introduced null pointer dereference in
case bq is NULL. This patch fixes it.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/power/bq2415x_charger.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sebastian Reichel Sept. 23, 2015, 5:04 p.m. UTC | #1
Hi Pali,

On Mon, Sep 21, 2015 at 04:58:20PM +0200, Pali Rohár wrote:
> Commit b68c3161430a (bq2415x_charger: Allow to load and use driver even if
> notify device is not registered yet) introduced null pointer dereference in
> case bq is NULL. This patch fixes it.
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, queued with proper "Fixes: " tag.

-- Sebastian
diff mbox

Patch

diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index ec212b5..4afd768 100644
--- a/drivers/power/bq2415x_charger.c
+++ b/drivers/power/bq2415x_charger.c
@@ -1704,7 +1704,7 @@  error_4:
 error_3:
 	bq2415x_power_supply_exit(bq);
 error_2:
-	if (bq->notify_node)
+	if (bq && bq->notify_node)
 		of_node_put(bq->notify_node);
 	kfree(name);
 error_1: