Skip to content

Commit

Permalink
msm: msm_bus: Add NULL pointer checks.
Browse files Browse the repository at this point in the history
Bus driver is crashing due to a NULL pointer
access sent by the client. A few NULL pointer
checks have been added to protect the driver
from invalid/NULL client handle.

CRs-Fixed: 458264
Change-Id: I822ad312ba1a0c0939d97eb92ea53094d408a836
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
  • Loading branch information
I-n-o-k authored and hellsgod committed Aug 14, 2013
1 parent cbc3631 commit e9f93e6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions arch/arm/mach-msm/msm_bus/msm_bus_arb.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -574,6 +574,10 @@ int msm_bus_scale_client_update_request(uint32_t cl, unsigned index)

curr = client->curr;
pdata = client->pdata;
if (!pdata) {
MSM_BUS_ERR("Null pdata passed to update-request\n");
return -ENXIO;
}

if (index >= pdata->num_usecases) {
MSM_BUS_ERR("Client %u passed invalid index: %d\n",
Expand Down Expand Up @@ -709,7 +713,7 @@ void msm_bus_scale_client_reset_pnodes(uint32_t cl)
{
int i, src, pnode, index;
struct msm_bus_client *client = (struct msm_bus_client *)(cl);
if (IS_ERR(client)) {
if (IS_ERR_OR_NULL(client)) {
MSM_BUS_ERR("msm_bus_scale_reset_pnodes error\n");
return;
}
Expand All @@ -730,7 +734,7 @@ void msm_bus_scale_client_reset_pnodes(uint32_t cl)
void msm_bus_scale_unregister_client(uint32_t cl)
{
struct msm_bus_client *client = (struct msm_bus_client *)(cl);
if (IS_ERR(client) || (!client))
if (IS_ERR_OR_NULL(client))
return;
if (client->curr != 0)
msm_bus_scale_client_update_request(cl, 0);
Expand Down

0 comments on commit e9f93e6

Please sign in to comment.