2017-07-31 04:32:12

by Keerthy

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

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 <[email protected]>
---

Changes in v2:

* Fixed returning an int to returning pointer.

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

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);

--
1.9.1


2017-07-31 20:09:33

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH v2] soc: ti: knav: Add a NULL pointer check for kdev in knav_pool_create

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 <[email protected]>
> ---
>
> Changes in v2:
>
> * Fixed returning an int to returning pointer.

Thanks. Will add it to the queue.

2017-08-21 05:45:32

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH v2] soc: ti: knav: Add a NULL pointer check for kdev in knav_pool_create

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 <[email protected]>
> ---
>
> Changes in v2:
>
> * Fixed returning an int to returning pointer.
FWIW, Acked-by: Santosh Shilimkar <[email protected]>

Can you please also apply this fix in your fixes branch ?

2017-08-21 07:21:10

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH v2] soc: ti: knav: Add a NULL pointer check for kdev in knav_pool_create

On Mon, Aug 21, 2017 at 7:44 AM, [email protected]
<[email protected]> 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 <[email protected]>
>> ---
>>
>> Changes in v2:
>>
>> * Fixed returning an int to returning pointer.
>
> FWIW, Acked-by: Santosh Shilimkar <[email protected]>
>
> Can you please also apply this fix in your fixes branch ?

Applied now, thanks!

Arnd