X-Received: by 2002:a05:6402:13c2:b0:410:8140:3178 with SMTP id a2-20020a05640213c200b0041081403178mr897493edx.299.1645644649726; Wed, 23 Feb 2022 11:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645644649; cv=none; d=google.com; s=arc-20160816; b=MuaR1oS0/g55u/dNc/P/96ftIMvJDfcrMIV0Ty4jupys8CqN7cA01atY/JuSh6b5Zg BOIKN5AwlUEaexVBj0IB1iyXwHPPyO9LSqp6b3Ow2FgLYLH4pM+EW9Hd0rs0qDtbcoe9 Q3FaaSu/yOo64HowZFyiV200EmWFD+GnGbwLNqMR3TBtyIwSyHV+tNC7l/IUB4GxwqmZ 2Y9Pg7d4kn1fEsGWKPHFSyERiVJSToCnzujHqX0kVGgDvZWs41+ELVfokbDzJ+Yjo1gP hqBNL9O0572ELu4BVjPOfYlwHNI7bJiNw7YH2C74pCuUutCFPH8KhM9KkqILurmOYFiN vPhw== 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=6kmYalWKPfFv5VRw+oGSxmK6RPimpkHdVtl6uKB49Rw=; b=wR+cf30kLCFBGbDWEgwfO+dtR+X15iwV8edfV7tfn+j7nBzwwquufLW6FJZoJVXS+z RdXt6eDClbKI1QI/bf3Pq6SUoOaPMERQxEFAuQwu7O7v9UMNDa4rejEL/kJ/PabZLeLy kHVWH5Yyrczt/Qpzg+mdC0wGQa7cU6PCANi6yC4WypZwksEccW0+FmQZQbX+HxHqDp5m S0ToxCHKeDwVO/HBXZBnyMZbTow1Oo45fBtfkaew0jw+C8FoQ2sg3s21GWka3RPJGljR oELhbHTWBb5hKzLs0SaZacHypmqOZsm7rLJcELCs1OvHoK1jxcDxefEkqoOXcmv9R3op xd4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=lypfQ5EH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6si280342ejo.931.2022.02.23.11.30.25; Wed, 23 Feb 2022 11:30:49 -0800 (PST) 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; dkim=pass header.i=@canonical.com header.s=20210705 header.b=lypfQ5EH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244272AbiBWTPJ (ORCPT + 99 others); Wed, 23 Feb 2022 14:15:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244227AbiBWTO5 (ORCPT ); Wed, 23 Feb 2022 14:14:57 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CADD403C2 for ; Wed, 23 Feb 2022 11:14:29 -0800 (PST) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 5ACE240312 for ; Wed, 23 Feb 2022 19:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645643665; bh=6kmYalWKPfFv5VRw+oGSxmK6RPimpkHdVtl6uKB49Rw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lypfQ5EHzpPmMptBnb1UN2iDFehpADD2VaDxcZwFK3pUxK58kF5AOQV48s64IfLTr Vqhh3CRJ+x2XxCGdvUTryHx68LR1CYFIl7nFH7uLw4C5/JplFp6fPsVYqSOZy9yk1I WEDg5qj5nxzd/uUGk0dXdLCbFc8azwjZc6ZtJKqAg9h8sKbIekQyfcRMElOwwp5X78 96Bf7WiFsP0OHi+sWOgnbgqljfBGuUt3Y5ZDjOjpnis9IgvSt0Igr6Ni2Z+HksoQQ4 f+PVM6Dn2KeDR2gp8YLzRhS/gGzj9bgI3cJr0VUtTt7XSytE/5aQwDRvw6tNjFRmL8 +G1t7eZX4F5KQ== Received: by mail-wr1-f72.google.com with SMTP id p9-20020adf9589000000b001e333885ac1so10604299wrp.10 for ; Wed, 23 Feb 2022 11:14:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6kmYalWKPfFv5VRw+oGSxmK6RPimpkHdVtl6uKB49Rw=; b=Z1zoE3NITSVWyJU58wB9ACxgvIetq1vTaOg95ZiKnpkVRtTERQt0dwb4ZyZULXQ5JY kAmeYR0iqOX4cj1tB0O857VkkzvuRGsRjvDBbnpjufIVNec2ezJx0sV/vy+VKQJlA9Op 8Ssx27gUCGkFnbvAPWE3WvI5vdl7jA7kWM0ulilUwOW/NqSGWX/m0pmr4Hnbl9phJMIe 0GbbxXJBwk/G0x8pyM9dVQHnsFwAmUwN1CGgRBZS1GT9IXvOjNh29Na1qi4j0fB79M7t RIxcDBOwak/v8NRmavAHTCSGu4jB7z/OA4mZxmISbN05VQXoz20jHWwrhcxOcoU/0c7p fk3Q== X-Gm-Message-State: AOAM5327UG5HjFFg7V8put9W7NqkwBzueUjSPxvIid4XQK7OhAnqiVXm 8qHRevwX/2ijEXAQf0JzBRsy3Z4Wykzh8DJP2YS2+wTx9hdaVicbYSxb1CIFxZyfQm/znNq9VlN 6fB1oO40JSOnCbX6sba08lIIz2MXcYPHUAxIkpUQnHA== X-Received: by 2002:a17:906:8517:b0:6d0:1de8:cb6e with SMTP id i23-20020a170906851700b006d01de8cb6emr879393ejx.686.1645643637572; Wed, 23 Feb 2022 11:13:57 -0800 (PST) X-Received: by 2002:a17:906:8517:b0:6d0:1de8:cb6e with SMTP id i23-20020a170906851700b006d01de8cb6emr879348ejx.686.1645643637394; Wed, 23 Feb 2022 11:13:57 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id q5sm212611ejc.115.2022.02.23.11.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 11:13:56 -0800 (PST) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Stuart Yoder , Laurentiu Tudor , Abel Vesa , Shawn Guo , Sascha Hauer , Fabio Estevam , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Bjorn Helgaas , Bjorn Andersson , Mathieu Poirier , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Andy Gross , Srinivas Kandagatla , Mark Brown , "Michael S. Tsirkin" , Jason Wang , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-spi@vger.kernel.org, virtualization@lists.linux-foundation.org, Linus Torvalds Cc: Rasmus Villemoes , Krzysztof Kozlowski Subject: [PATCH v2 04/11] hv: vmbus: use helper for safer setting of driver_override Date: Wed, 23 Feb 2022 20:13:03 +0100 Message-Id: <20220223191310.347669-5-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> References: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Use a helper for seting driver_override to reduce amount of duplicated code. Signed-off-by: Krzysztof Kozlowski --- drivers/hv/vmbus_drv.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 12a2b37e87f3..f2435cc8b680 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -575,31 +575,15 @@ static ssize_t driver_override_store(struct device *dev, const char *buf, size_t count) { struct hv_device *hv_dev = device_to_hv_device(dev); - char *driver_override, *old, *cp; + int ret; /* We need to keep extra room for a newline */ if (count >= (PAGE_SIZE - 1)) return -EINVAL; - driver_override = kstrndup(buf, count, GFP_KERNEL); - if (!driver_override) - return -ENOMEM; - - cp = strchr(driver_override, '\n'); - if (cp) - *cp = '\0'; - - device_lock(dev); - old = hv_dev->driver_override; - if (strlen(driver_override)) { - hv_dev->driver_override = driver_override; - } else { - kfree(driver_override); - hv_dev->driver_override = NULL; - } - device_unlock(dev); - - kfree(old); + ret = driver_set_override(dev, &hv_dev->driver_override, buf); + if (ret) + return ret; return count; } -- 2.32.0