From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.01.org
Subject: Re: [PATCH v2 1/2] scan: refactor start_next_scan_request to not send duplicate requests
Date: Thu, 04 Jun 2020 13:31:09 -0500 [thread overview]
Message-ID: <053d938e-c873-79f1-ca84-020af2e2f285@gmail.com> (raw)
In-Reply-To: <20200601171117.122574-1-alsi@bang-olufsen.dk>
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
Hi Alvin,
On 6/1/20 12:11 PM, Alvin Šipraga wrote:
> If start_scan_next_request() is called while a scan request
> (NL80211_CMD_TRIGGER_SCAN) is still running, the same scan request will
> be sent again. Add a check in the function to avoid sending a request if
> one is already in progress.
>
> This also fixes a crash that occurs if the following conditions are met:
> - the duplicated request is the only request in the scan request
> queue, and
> - both scan requests fail with an error not EBUSY.
Nice catch on this. Scanning code is some of the most complex in the
project, so kudos.
>
> In this case, the first callback to scan_request_triggered() will delete
> the request from the scan request queue. The second callback will find
> an empty queue and consequently pass a NULL scan_request pointer to
> scan_request_failed(), causing a segmentation fault.
So for my own education, can you elaborate a bit more on how this is
actually triggered? I'm guessing that there are pending scans (probably
triggered by invocation of Scan() via D-Bus?). But an exact sequence of
what happens would be nice.
> ---
> src/scan.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/scan.c b/src/scan.c
> index 718f7497..106fa81c 100644
> --- a/src/scan.c
> +++ b/src/scan.c
> @@ -839,6 +839,9 @@ static bool start_next_scan_request(struct scan_context *sc)
> if (sc->state != SCAN_STATE_NOT_RUNNING)
> return true;
>
> + if (sc->start_cmd_id)
> + return true;
> +
So I think Andrew's suggestion of also checking for get_scan_id being
not zero also makes sense. It would keep things consistent with the
comment in scan_notify where it says that we do not start the next
request until GET_SCAN has been done.
Regards,
-Denis
next prev parent reply other threads:[~2020-06-04 18:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 17:11 [PATCH v2 1/2] scan: refactor start_next_scan_request to not send duplicate requests Alvin =?unknown-8bit?q?=C5=A0ipraga?=
2020-06-01 17:11 ` [PATCH v2 2/2] scan: refactor scan_common to not scan while scanning is suspended Alvin =?unknown-8bit?q?=C5=A0ipraga?=
2020-06-04 18:19 ` Denis Kenzior
2020-06-02 8:45 ` [PATCH v2 1/2] scan: refactor start_next_scan_request to not send duplicate requests Andrew Zaborowski
2020-06-04 18:31 ` Denis Kenzior [this message]
2020-06-06 17:33 ` Alvin =?unknown-8bit?q?=C5=A0ipraga?=
2020-06-09 11:49 ` Alvin =?unknown-8bit?q?=C5=A0ipraga?=
2020-06-09 20:10 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=053d938e-c873-79f1-ca84-020af2e2f285@gmail.com \
--to=denkenz@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox