msm ipa3: fix blocking faulty IOCTLs

This change prevents blocking IOCTLs with wrong command
number or wrong magic Number. IOCTL handler should first
check that the command is valid and only then wait for
IPA driver initializations to finish.

CRs-Fixed: 1094653
Signed-off-by: Amir Levy <alevy@codeaurora.org>
Change-Id: I578dc96da96f7c10be51eac1f8b3c190e45dcfcf
This commit is contained in:
Amir Levy 2016-11-28 12:12:01 +02:00 committed by Gerrit - the friendly Code Review server
parent d43553d47d
commit c07808d8db

View file

@ -624,16 +624,16 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
IPADBG("cmd=%x nr=%d\n", cmd, _IOC_NR(cmd));
if (!ipa3_is_ready()) {
IPAERR("IPA not ready, waiting for init completion\n");
wait_for_completion(&ipa3_ctx->init_completion_obj);
}
if (_IOC_TYPE(cmd) != IPA_IOC_MAGIC)
return -ENOTTY;
if (_IOC_NR(cmd) >= IPA_IOCTL_MAX)
return -ENOTTY;
if (!ipa3_is_ready()) {
IPAERR("IPA not ready, waiting for init completion\n");
wait_for_completion(&ipa3_ctx->init_completion_obj);
}
IPA_ACTIVE_CLIENTS_INC_SIMPLE();
switch (cmd) {