usb: gadget: f_gsi: bail out if opts is null

Currently, functions gsi_inst_clean & gsi_free_inst utilises
gsi_opts without any check, however there is a possibility
that the opts structure could become NULL. In such case, due
to lack of if checks can result in NULL pointer dereference.

Change-Id: I548690e2eee377b5292f258972ae7e38417f3085
Signed-off-by: Prashanth K <[email protected]>
This commit is contained in:
Prashanth K 2023-04-28 12:37:42 +05:30
commit 63a32bf361

View file

@ -3849,6 +3849,9 @@ static struct config_item_type gsi_func_rmnet_type = {
static void gsi_inst_clean(struct gsi_opts *opts)
{
if (!opts)
return;
if (opts->gsi->c_port.cdev.dev) {
struct cdev *cdev = &opts->gsi->c_port.cdev;
struct f_gsi *gsi = opts->gsi;
@ -3962,7 +3965,7 @@ static void gsi_free_inst(struct usb_function_instance *f)
enum ipa_usb_teth_prot prot_id;
struct f_gsi *gsi;
if (!opts->gsi)
if (!opts || !opts->gsi)
return;
prot_id = opts->gsi->prot_id;