From patchwork Tue Jul 27 10:05:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 486680 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp68895jas; Tue, 27 Jul 2021 03:05:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4WUPUmEInIAClEmgD6FKVxklRjc89jnjx8XGmumkRPfMgaaJhd6O0xMIYia2lP+9qANjB X-Received: by 2002:a17:906:43c9:: with SMTP id j9mr20824858ejn.57.1627380344339; Tue, 27 Jul 2021 03:05:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627380344; cv=none; d=google.com; s=arc-20160816; b=VGwXDssq/7COuY7tE1nP8u72TLZfIdZ6amFA5Em0Fq3IT91MGov/Yx3k2rX/KF6gBi rLVBPclx065T9ipsxYG4GOFrpDociKwDiParzeDBeD13zIxFBnqaejO2vJtB+spDI3YR 4Ss95k8gW0sjlwkJI6LUgmzzPn1aoZcZ/heEaabwrRdkwQgHDS3eWGWH4C5p3hLSAlve q+7+XjmJ2sTh5PAfZmCHJCee4zIcLluwmc5KCNobEX2cHGRIz46EhD6OdpkgzYOdu2fN 9dQos/sujRLoORZqFuARFnzFQcNHs5lghw2cHBMiCRUc1VQXJsSYl/BzA5KyJInh8BpZ XAOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Aj50P04AHvnNUWvmjhxhomiq5h7kyJzSIwB9k4QqcrQ=; b=nIsbYmzQsfWVpsIuxq14L+BvL5C/66Qi/O/1dDh9pABnAoqgbkgnSgi7oOTo1RUHgc k41Xpcmgj2rHlcqyeCHoncA/SQ4Hbp8GSF0h+KTaXGvJxyX3u0MGT0p8a2xgFC+oF0XQ aG5t4YkoaN3yZlKPD3KVL6GTBsMFg7npMTRYJHXdtwM6pFYnidgwiuw0FG7I2BtIMcnS iRuHKlgGDyZ7ENjNdweEdN1FrEjDmwx3sCXPcCuB127jtKjZwEQ9UIjT13gwr5E4t5/F kujZuw7jKMWGa152LymrmWL3BVzpr4DXPVOxMbM50a8sLOYYrKtty6LYzJlMNb/0xszT OsIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FQiK5B8I; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc24si2497771edb.193.2021.07.27.03.05.44; Tue, 27 Jul 2021 03:05:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FQiK5B8I; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236155AbhG0KFm (ORCPT + 4 others); Tue, 27 Jul 2021 06:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236104AbhG0KFk (ORCPT ); Tue, 27 Jul 2021 06:05:40 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C5F2C061757 for ; Tue, 27 Jul 2021 03:05:40 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r2so14546862wrl.1 for ; Tue, 27 Jul 2021 03:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Aj50P04AHvnNUWvmjhxhomiq5h7kyJzSIwB9k4QqcrQ=; b=FQiK5B8I6cuLEdYVKKJu2fURVfzQ149zbr6uDclVhTnuJ43t+E8+iWIIETJUdwCpBQ uURHJqr7cZbZSk5GdVIN1T/drYRfq4/Qd4BwMUV5ljMayUQ81w49bHc1PuIuhHj4UXTc 3Xowzl/aMrz8cS5D6c251+A+FfQY6iJ9XL7YDKcc4xM3AJi1pqF9+DADNWZoSLr+ZFG9 7GGjzldwggT8/UrgUO0GWkhsQ7sMU/ZYl8fdhVHK3GpwzimgjWeOlKRKwg5nuA+GDJHE Q9QioJrl67ByMPdm60RuQEeXoHIf2EWsckyO6cVX9FuitJxC4dEMERrXMBB9pv7nPnc/ PqHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Aj50P04AHvnNUWvmjhxhomiq5h7kyJzSIwB9k4QqcrQ=; b=Y8JOZ6UJbcb5JdcCkFRgo02xiU/03XrnBsWELWPIgDQj7RqNAbQ+tyReIew6Mcq9kx gKKJf/o/smbbnR/hcOGnn+93cWJfKengtSjto+jreImHdVjGO+N2DFx1ohFNkGa55VTw VliXYMZShAQj2edNCbrUwiyznrQHCXLysRQPiohwuld5rcI+4Fvv0/sTkJ/rs/s/spwp YVkoxT0t33amwWE1Ld2VudwO/cW2MYg4+5VBK0lD8EH6Ju9hZF3HqjJeAVorDB+jvlGz n4OVVKAxSzLf2a3LJT/4vHSp4paG8Lb0yRlUAn/pKYIV1cv/MpvpRtp1Fr8hzFtMkuXB SHPg== X-Gm-Message-State: AOAM531Url74Smw9gPmyWwC1KqQCxaXytX6hN0EcDU5O5blAS0q0Q34n Jse5tqQqYOEIoYGTu6pAswE+nQ== X-Received: by 2002:adf:ed0a:: with SMTP id a10mr15058200wro.30.1627380338637; Tue, 27 Jul 2021 03:05:38 -0700 (PDT) Received: from arch-thunder.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v5sm2813221wrd.74.2021.07.27.03.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 03:05:38 -0700 (PDT) From: Rui Miguel Silva To: Greg Kroah-Hartman , Dan Carpenter Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH 3/3] usb: isp1760: rework cache initialization error handling Date: Tue, 27 Jul 2021 11:05:16 +0100 Message-Id: <20210727100516.4190681-4-rui.silva@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727100516.4190681-1-rui.silva@linaro.org> References: <20210727100516.4190681-1-rui.silva@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org If we fail to create qtd cache we were not destroying the urb_listitem, rework the error handling logic to cope with that. Signed-off-by: Rui Miguel Silva --- drivers/usb/isp1760/isp1760-hcd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) -- 2.32.0 diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index a018394d54f8..825be736be33 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -2527,17 +2527,23 @@ int __init isp1760_init_kmem_once(void) SLAB_MEM_SPREAD, NULL); if (!qtd_cachep) - return -ENOMEM; + goto destroy_urb_listitem; qh_cachep = kmem_cache_create("isp1760_qh", sizeof(struct isp1760_qh), 0, SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); - if (!qh_cachep) { - kmem_cache_destroy(qtd_cachep); - return -ENOMEM; - } + if (!qh_cachep) + goto destroy_qtd; return 0; + +destroy_qtd: + kmem_cache_destroy(qtd_cachep); + +destroy_urb_listitem: + kmem_cache_destroy(urb_listitem_cachep); + + return -ENOMEM; } void isp1760_deinit_kmem_cache(void)