diff mbox

[v2] soc: ti: knav: Add a NULL pointer check for kdev in knav_pool_create

Message ID 1501475496-10267-1-git-send-email-j-keerthy@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

J, KEERTHY July 31, 2017, 4:31 a.m. UTC
knav_pool_create is an exported function. In the event of a call
before knav_queue_probe, we encounter a NULL pointer dereference
in the following line. Hence return -EPROBE_DEFER to the caller till
the kdev pointer is non-NULL.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Changes in v2:

  * Fixed returning an int to returning pointer.

 drivers/soc/ti/knav_qmss_queue.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Santosh Shilimkar July 31, 2017, 8:09 p.m. UTC | #1
On 7/30/2017 9:31 PM, Keerthy wrote:
> knav_pool_create is an exported function. In the event of a call
> before knav_queue_probe, we encounter a NULL pointer dereference
> in the following line. Hence return -EPROBE_DEFER to the caller till
> the kdev pointer is non-NULL.
> 
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> ---
> 
> Changes in v2:
> 
>    * Fixed returning an int to returning pointer.

Thanks. Will add it to the queue.
Santosh Shilimkar Aug. 21, 2017, 5:44 a.m. UTC | #2
Hi Arnd,

On 7/30/17 9:31 PM, Keerthy wrote:
> knav_pool_create is an exported function. In the event of a call
> before knav_queue_probe, we encounter a NULL pointer dereference
> in the following line. Hence return -EPROBE_DEFER to the caller till
> the kdev pointer is non-NULL.
> 
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> ---
> 
> Changes in v2:
> 
>    * Fixed returning an int to returning pointer.
FWIW, Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

Can you please also apply this fix in your fixes branch ?
Arnd Bergmann Aug. 21, 2017, 7:21 a.m. UTC | #3
On Mon, Aug 21, 2017 at 7:44 AM, santosh.shilimkar@oracle.com
<santosh.shilimkar@oracle.com> wrote:
> Hi Arnd,
>
> On 7/30/17 9:31 PM, Keerthy wrote:
>>
>> knav_pool_create is an exported function. In the event of a call
>> before knav_queue_probe, we encounter a NULL pointer dereference
>> in the following line. Hence return -EPROBE_DEFER to the caller till
>> the kdev pointer is non-NULL.
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> ---
>>
>> Changes in v2:
>>
>>    * Fixed returning an int to returning pointer.
>
> FWIW, Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
>
> Can you please also apply this fix in your fixes branch ?

Applied now, thanks!

      Arnd
diff mbox

Patch

diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 279e7c5..d91626b 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -745,6 +745,9 @@  void *knav_pool_create(const char *name,
 	bool slot_found;
 	int ret;
 
+	if (!kdev)
+		return ERR_PTR(-EPROBE_DEFER);
+
 	if (!kdev->dev)
 		return ERR_PTR(-ENODEV);