Commit 05a1308a authored by Simon Horman's avatar Simon Horman Committed by Tony Nguyen

ice: Don't dereference NULL in ice_gnss_read error path

If pf is NULL in ice_gnss_read() then it will be dereferenced
in the error path by a call to dev_dbg(ice_pf_to_dev(pf), ...).

Avoid this by simply returning in this case.
If logging is desired an alternate approach might be to
use pr_err() before returning.

Flagged by Smatch as:

  .../ice_gnss.c:196 ice_gnss_read() error: we previously assumed 'pf' could be null (see line 131)

Fixes: 43113ff7 ("ice: add TTY for GNSS module for E810T device")
Signed-off-by: default avatarSimon Horman <horms@kernel.org>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Tested-by: Sunitha Mekala <sunithax.d.mekala@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 6c0ec7ab
...@@ -96,12 +96,7 @@ static void ice_gnss_read(struct kthread_work *work) ...@@ -96,12 +96,7 @@ static void ice_gnss_read(struct kthread_work *work)
int err = 0; int err = 0;
pf = gnss->back; pf = gnss->back;
if (!pf) { if (!pf || !test_bit(ICE_FLAG_GNSS, pf->flags))
err = -EFAULT;
goto exit;
}
if (!test_bit(ICE_FLAG_GNSS, pf->flags))
return; return;
hw = &pf->hw; hw = &pf->hw;
...@@ -159,7 +154,6 @@ static void ice_gnss_read(struct kthread_work *work) ...@@ -159,7 +154,6 @@ static void ice_gnss_read(struct kthread_work *work)
free_page((unsigned long)buf); free_page((unsigned long)buf);
requeue: requeue:
kthread_queue_delayed_work(gnss->kworker, &gnss->read_work, delay); kthread_queue_delayed_work(gnss->kworker, &gnss->read_work, delay);
exit:
if (err) if (err)
dev_dbg(ice_pf_to_dev(pf), "GNSS failed to read err=%d\n", err); dev_dbg(ice_pf_to_dev(pf), "GNSS failed to read err=%d\n", err);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment