Skip to contentSkip to conversation

USB: quirks: simplify quirk handling.

PATCH In review Pavel Machek 3 participants 5 messages Sep 21, 2020 – Sep 23, 2020 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: quirks: simplify quirk handling.

Simplify quirk handling.

drivers/usb/core/quirks.c +4 -9
index f232914de5fd..167b6ac428a3 100644
@@ -56,18 +56,13 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
 		if (val[i] == ',')
 			quirk_count++;
 
-	if (quirk_list) {
-		kfree(quirk_list);
-		quirk_list = NULL;
-	}
-
+	kfree(quirk_list);
 	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
 			     GFP_KERNEL);
 	if (!quirk_list) {
 		quirk_count = 0;
-		mutex_unlock(&quirk_mutex);
-		kfree(val);
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto unlock;
 	}
 
 	for (i = 0, p = val; p && *p;) {
@@ -153,7 +148,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
 	mutex_unlock(&quirk_mutex);
 	kfree(val);
 
-	return 0;
+	return err;
 }
 
 static const struct kernel_param_ops quirks_param_ops = {
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#1 lore raw
Quoted 1 line · Pavel Machek

Simplify quirk handling.

In what way?

Please be more descriptive in your changelog and resend.

thanks,

greg k-h

#2 lore raw
Quoted 6 lines · Greg KH
Quoted 1 line · Pavel Machek

Simplify quirk handling.

In what way?

Please be more descriptive in your changelog and resend.

Have you looked at the patch below? Please apply the patch. You are free to edit the changelog if you feel the need.

Pavel

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
maintainer
#3 lore raw
Quoted 10 lines · Pavel Machek
Quoted 6 lines · Greg KH
Quoted 1 line · Pavel Machek

Simplify quirk handling.

In what way?

Please be more descriptive in your changelog and resend.

Have you looked at the patch below? Please apply the patch. You are free to edit the changelog if you feel the need.

I am also free to ignore patches with changelogs that do not say anything of consequence, which I will do here.

greg k-h

#4 lore raw
In reply to Pavel Machek
Quoted 1 line · Pavel Machek

Simplify quirk handling.

This patch seems to contain two different "simplifications" in one. I have no objections against the first simplification:

- if (quirk_list) {
- kfree(quirk_list);
- quirk_list = NULL;
- }
-
+ kfree(quirk_list);
quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
GFP_KERNEL);

Since kfree() does nothing to nullpointers, all lines that are cut seem to be superfluous.

The second simplification does not seem to introduce any new bugs as far as I can tell. Due to lack of experience, I shall refrain from commenting on whether or not it simplifies things.