From: rickyniu <rickyniu@google.com>
To: balbi@kernel.org, gregkh@linuxfoundation.org,
astrachan@google.com, rickyniu@google.com,
amit.pundir@linaro.org, lockwood@android.com, benoit@android.com,
jackp@codeaurora.org, vvreddy@codeaurora.org
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
kyletso@google.com
Subject: [PATCH 2/3] ANDROID: USB: f_accessory: Check dev pointer before decoding ctrl request
Date: Mon, 12 Oct 2020 19:10:23 +0800 [thread overview]
Message-ID: <20201012111024.2259162-3-rickyniu@google.com> (raw)
In-Reply-To: <20201012111024.2259162-1-rickyniu@google.com>
From: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
In case of poweroff charging mode, accessory function instance
is not created and due to this, _acc_dev will be NULL. If target
is connected to Accessory dock in poweroff charging mode, there
is a chance dev pointer is accessed, which is NULL. Hence add a
check before processing control request and return error if it is
NULL.
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: rickyniu <rickyniu@google.com>
---
drivers/usb/gadget/function/f_accessory.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c
index 514eadee1793..5ed80940b9bf 100644
--- a/drivers/usb/gadget/function/f_accessory.c
+++ b/drivers/usb/gadget/function/f_accessory.c
@@ -833,6 +833,12 @@ int acc_ctrlrequest(struct usb_composite_dev *cdev,
u16 w_length = le16_to_cpu(ctrl->wLength);
unsigned long flags;
+ /*
+ * If instance is not created which is the case in power off charging
+ * mode, dev will be NULL. Hence return error if it is the case.
+ */
+ if (!dev)
+ return -ENODEV;
/*
printk(KERN_INFO "acc_ctrlrequest "
"%02x.%02x v%04x i%04x l%u\n",
--
2.28.0.1011.ga647a8990f-goog
next prev parent reply other threads:[~2020-10-12 11:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 11:10 [PATCH 0/3] f_accessory upstream rickyniu
2020-10-12 11:10 ` [PATCH 1/3] ANDROID: usb: gadget: f_accessory: Add Android Accessory function rickyniu
2020-10-12 11:24 ` Greg KH
2020-10-12 11:28 ` Greg KH
2020-10-12 15:58 ` Felipe Balbi
2020-10-12 11:10 ` rickyniu [this message]
2020-10-12 11:10 ` [PATCH 3/3] ANDROID: usb: f_accessory: send uevent for 51,52 requests rickyniu
2020-10-12 11:23 ` Greg KH
2020-10-12 11:28 ` Greg KH
2020-10-12 11:29 ` [PATCH 0/3] f_accessory upstream Greg KH
2020-10-12 15:39 ` Felipe Balbi
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=20201012111024.2259162-3-rickyniu@google.com \
--to=rickyniu@google.com \
--cc=amit.pundir@linaro.org \
--cc=astrachan@google.com \
--cc=balbi@kernel.org \
--cc=benoit@android.com \
--cc=gregkh@linuxfoundation.org \
--cc=jackp@codeaurora.org \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lockwood@android.com \
--cc=vvreddy@codeaurora.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;
as well as URLs for NNTP newsgroup(s).