lkml.org 
[lkml]   [2018]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL for 4.9 213/281] [media] cx25840: fix unchecked return values
    Date
    From: Pan Bian <bianpan2016@163.com>

    [ Upstream commit 35378ce143071c2a6bad4b59a000e9b9f8f6ea67 ]

    In functions cx25840_initialize(), cx231xx_initialize(), and
    cx23885_initialize(), the return value of create_singlethread_workqueue()
    is used without validation. This may result in NULL dereference and cause
    kernel crash. This patch fixes it.

    Signed-off-by: Pan Bian <bianpan2016@163.com>
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    ---
    drivers/media/i2c/cx25840/cx25840-core.c | 36 +++++++++++++++++++-------------
    1 file changed, 21 insertions(+), 15 deletions(-)

    diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
    index 142ae28803bb..d558ed3e59c6 100644
    --- a/drivers/media/i2c/cx25840/cx25840-core.c
    +++ b/drivers/media/i2c/cx25840/cx25840-core.c
    @@ -420,11 +420,13 @@ static void cx25840_initialize(struct i2c_client *client)
    INIT_WORK(&state->fw_work, cx25840_work_handler);
    init_waitqueue_head(&state->fw_wait);
    q = create_singlethread_workqueue("cx25840_fw");
    - prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
    - queue_work(q, &state->fw_work);
    - schedule();
    - finish_wait(&state->fw_wait, &wait);
    - destroy_workqueue(q);
    + if (q) {
    + prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
    + queue_work(q, &state->fw_work);
    + schedule();
    + finish_wait(&state->fw_wait, &wait);
    + destroy_workqueue(q);
    + }

    /* 6. */
    cx25840_write(client, 0x115, 0x8c);
    @@ -634,11 +636,13 @@ static void cx23885_initialize(struct i2c_client *client)
    INIT_WORK(&state->fw_work, cx25840_work_handler);
    init_waitqueue_head(&state->fw_wait);
    q = create_singlethread_workqueue("cx25840_fw");
    - prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
    - queue_work(q, &state->fw_work);
    - schedule();
    - finish_wait(&state->fw_wait, &wait);
    - destroy_workqueue(q);
    + if (q) {
    + prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
    + queue_work(q, &state->fw_work);
    + schedule();
    + finish_wait(&state->fw_wait, &wait);
    + destroy_workqueue(q);
    + }

    /* Call the cx23888 specific std setup func, we no longer rely on
    * the generic cx24840 func.
    @@ -752,11 +756,13 @@ static void cx231xx_initialize(struct i2c_client *client)
    INIT_WORK(&state->fw_work, cx25840_work_handler);
    init_waitqueue_head(&state->fw_wait);
    q = create_singlethread_workqueue("cx25840_fw");
    - prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
    - queue_work(q, &state->fw_work);
    - schedule();
    - finish_wait(&state->fw_wait, &wait);
    - destroy_workqueue(q);
    + if (q) {
    + prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
    + queue_work(q, &state->fw_work);
    + schedule();
    + finish_wait(&state->fw_wait, &wait);
    + destroy_workqueue(q);
    + }

    cx25840_std_setup(client);

    --
    2.14.1
    \
     
     \ /
      Last update: 2018-03-19 18:59    [W:4.075 / U:0.804 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site