Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef02260a authored by Hemant Kumar's avatar Hemant Kumar Committed by Mayank Rana
Browse files

usb: gadget: f_gsi: Fix return type for name_to_prot_id()



name_to_prot_id() returns -EINVAL for error case when return
type is enum usb_prot_id. This return type is compared against
< 0 without type casting to integer which returns false. As a
result invalid prot_id is indexed for __gsi array. Fix the issue
by changing return type to int.

Change-Id: I0d833d59e95e2257255e841913a2eed5204c6ef5
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 37a2d589
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -3599,10 +3599,9 @@ static struct config_item_type gsi_func_rndis_type = {
static int gsi_set_inst_name(struct usb_function_instance *fi,
	const char *name)
{
	int name_len, ret = 0;
	int name_len, prot_id, ret = 0;
	struct gsi_opts *opts;
	struct f_gsi *gsi;
	enum usb_prot_id prot_id;

	opts = container_of(fi, struct gsi_opts, func_inst);

+1 −1
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ static inline struct gsi_opts *to_gsi_opts(struct config_item *item)
			    func_inst.group);
}

static enum usb_prot_id name_to_prot_id(const char *name)
static int name_to_prot_id(const char *name)
{
	if (!name)
		goto error;