Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5206367imw; Wed, 20 Jul 2022 00:43:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1th+hLjHFC1qdudZvAzj7qfypQ376oqh9aAwUOQxVuZ/kRKPpFM+llzi0QMrEDMFFTvSVYj X-Received: by 2002:a17:907:8a14:b0:72b:76d0:520 with SMTP id sc20-20020a1709078a1400b0072b76d00520mr33981900ejc.468.1658303009967; Wed, 20 Jul 2022 00:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658303009; cv=none; d=google.com; s=arc-20160816; b=KXz7RvsKw1KjMox+vJ1OkmdKp2yFuabDu5+qWP9aSfKA38Ea8dTd9kMmHgB3QOXTec wlXZ60cT8AtHlKTDgxHZV12espk1J33+ilmzznKFT7GvT3EUvFFzuiZIYMY7uAEcZqpN wTDlfeQCpco4k9hXf0NhVT47uKI74astSidglRigAXO2mPPPBp1xunWGD0zBQnCT/t4z iZYsKRfYtEKl3WHrjmOUIlV0s2PkDptxwe0TNFoseWJQBUS/2Zw8/as2DqcF6yLL9fqN dHM96Rlc74/a2/7/kXuyZnpgKFqEM6sRsmhYS2Xpm4GdVsKHBjDxt7POmJDMgkd2QP1d UsZA== 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 :message-id:date:subject:cc:to:from; bh=pDOeZOW5i5tyX0wDFKXpgyt1eYoD+2/tpQ5fzIZBU3E=; b=DkTMtX/SmHqbrn9qGWu+rfmCzeUjDp97ljkUQG/bRfiQP2a14FR1FjWw/sdsrajOmM Yh2jUFtEyOIq9LPgNRGoBZkddOvP1R86knCf4B5Wk6pmBAsEp3nYReYIBmrcmWF1Imio 99glaBDk5gsL+dSi2HveI5sAbvxmHT97/SVYys0jomy5jwBNqSjvdmRKAyhOhovWySVV rZZ3UcpPRFJNDqedQYwwnegOpQTNlKvOEWbXypsm6xaTvjzWAlA4c8WJoKIOyDLxStrP j52SwPUjDThncfpiSZxKUVh8JUF3ZsjV5qI3v9pbwWQYcJ8d2epee4jbbHyZzf4KdmNp 5HZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh30-20020a1709076e9e00b0072b9928acfesi2070618ejc.581.2022.07.20.00.43.04; Wed, 20 Jul 2022 00:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbiGTHZM (ORCPT + 99 others); Wed, 20 Jul 2022 03:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiGTHZL (ORCPT ); Wed, 20 Jul 2022 03:25:11 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CBB6CD9; Wed, 20 Jul 2022 00:25:06 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 26K7OZAm016064-26K7OZAp016064 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 20 Jul 2022 15:24:40 +0800 From: Dongliang Mu To: Greg Kroah-Hartman , Dongliang Mu Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: trancevibrator: simplify tv_probe Date: Wed, 20 Jul 2022 15:23:43 +0800 Message-Id: <20220720072346.33511-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongliang Mu The function tv_probe does not need to invoke kfree when the allocation fails. So let's simplify the code of tv_probe. Another change is to remove a redundant space. Signed-off-by: Dongliang Mu --- drivers/usb/misc/trancevibrator.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 26baba3ab7d7..30d4d774d448 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c @@ -84,29 +84,22 @@ static int tv_probe(struct usb_interface *interface, { struct usb_device *udev = interface_to_usbdev(interface); struct trancevibrator *dev; - int retval; dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL); - if (!dev) { - retval = -ENOMEM; - goto error; - } + if (!dev) + return -ENOMEM; dev->udev = usb_get_dev(udev); usb_set_intfdata(interface, dev); return 0; - -error: - kfree(dev); - return retval; } static void tv_disconnect(struct usb_interface *interface) { struct trancevibrator *dev; - dev = usb_get_intfdata (interface); + dev = usb_get_intfdata(interface); usb_set_intfdata(interface, NULL); usb_put_dev(dev->udev); kfree(dev); -- 2.35.1