From patchwork Sat Jan 28 03:49:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9543013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C2D360415 for ; Sat, 28 Jan 2017 03:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49A5426E69 for ; Sat, 28 Jan 2017 03:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CB4728179; Sat, 28 Jan 2017 03:49:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95CF926E69 for ; Sat, 28 Jan 2017 03:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750762AbdA1Dt4 (ORCPT ); Fri, 27 Jan 2017 22:49:56 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:43239 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750742AbdA1Dtz (ORCPT ); Fri, 27 Jan 2017 22:49:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=C5LvzQHlqXniIVUupnFoKdzSAg0jtGpqN6z4XcvYjkU=; b=M9RBplIVIImvGE2oozAfsosxgF ET3FJHxAQvrDakcDVjtQ1Dvjn6qSIIJ8is1YvKU3zSCkrLrj22PP1PRxYcLVxsANh0Hc1qiNCssMJ QRkCRmACAl5JyzN8612LhsFheXZOcUCL7CezPWpr2O0kYsI5dT4oeddirYYAiX8pJZjEfyilyJfuG uF/Uf2CimILygWfTMSx75eYGJfCUv4xVh3x2oOgufKzCAi6gn6dlImoRHYpg8+grLWuuZisGBVc4G QIQO0rihG0/qpW/YhGlwA9KnFBEyucEuiSp0HkhfgfNfxyizxJaQUiDX7bj97wbMieDigX4ZZy88A kiK7Qu/Q==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:60244 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cXK1R-000o4q-LL; Sat, 28 Jan 2017 03:49:54 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Dmitry Torokhov , linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH] hwmon: Relax name attribute validation for new APIs Date: Fri, 27 Jan 2017 19:49:49 -0800 Message-Id: <1485575389-31616-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While invalid name attributes are really not desirable and do mess up libsensors, enforcing valid names has the detrimental effect of driving users away from using the new hardware monitoring API, especially those registering name attributes violating the ABI restrictions. Another undesirable side effect is that this violation and the resulting error may only be discovered some time after a conversion to the new API, which in turn may trigger a revert of that conversion. To solve the problem, relax validation and only issue a warning instead of returning an error if a name attribute violating the ABI is provided. This lets callers continue to provide invalid name attributes while notifying them about it. Many thanks are due to Dmitry Torokhov for the idea. Signed-off-by: Guenter Roeck Reviewed-by: Jean Delvare --- drivers/hwmon/hwmon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index affff8195fff..53c54a81f7ad 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -544,9 +544,10 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, struct device *hdev; int i, j, err, id; - /* Do not accept invalid characters in hwmon name attribute */ + /* Complain about invalid characters in hwmon name attribute */ if (name && (!strlen(name) || strpbrk(name, "-* \t\n"))) - return ERR_PTR(-EINVAL); + dev_warn(dev, "hwmon: '%s' is not a valid name attribute\n", + name); id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL); if (id < 0)