From patchwork Mon Sep 21 11:30:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 11789447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5181C59D for ; Mon, 21 Sep 2020 11:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4175920874 for ; Mon, 21 Sep 2020 11:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbgIULal (ORCPT ); Mon, 21 Sep 2020 07:30:41 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:35902 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbgIULal (ORCPT ); Mon, 21 Sep 2020 07:30:41 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id CF8711C0B81; Mon, 21 Sep 2020 13:30:39 +0200 (CEST) Date: Mon, 21 Sep 2020 13:30:39 +0200 From: Pavel Machek To: gregkh@linuxfoundation.org, stern@rowland.harvard.edu, kai.heng.feng@canonical.com, johan@kernel.org, tomasz@meresinski.eu, jonathan@jdcox.net, kerneldev@karsmulder.nl, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] USB: quirks: simplify quirk handling. Message-ID: <20200921113039.GA19862@duo.ucw.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Simplify quirk handling. Signed-off-by: Pavel Machek (CIP) diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index f232914de5fd..167b6ac428a3 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -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 = {