From patchwork Tue Jul 26 15:19:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9248331 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 B153B60757 for ; Tue, 26 Jul 2016 15:20:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1FD620008 for ; Tue, 26 Jul 2016 15:20:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94D1F26A4D; Tue, 26 Jul 2016 15:20:07 +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 75BB426D08 for ; Tue, 26 Jul 2016 15:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754478AbcGZPUA (ORCPT ); Tue, 26 Jul 2016 11:20:00 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:35747 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756077AbcGZPT7 (ORCPT ); Tue, 26 Jul 2016 11:19:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=s03D8r1X+F06VoF2ZqBwTqEOVnCWq859mYfJ2OQn6Tg=; b=XsPpOCM6iJaHF7 SYywrq/94eMQDsqbG68p+DPq6rzz52/SQKjT7JFUKh3ZffqmTmAksbuXYteouDiWh9EhWvLzN+RGk 5AMfi3OfuC03578jGblI214Lu/G5LZy+tTdAUnTYZKpCtfe818NPrYslCDXFTijRrIc5kcZU/CQ16 kAJu2rLPCd2t7MXViOPdEyf9m4PcEJRJn17IJVRLFyCWg3aAJHPlmvt/Mr5VGk52G253oYw/sMHdC rbrFBU1UwJgHTZO+ZCh4ynwJgS9YatoPWssl0INHI3XA3SvEVPrWuodVZJWKKmJe0I2FFyP/10pTS V6oUV844bIJFi8V5zhGA==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:37480 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bS49B-003SB2-9u; Tue, 26 Jul 2016 15:19:53 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH] hwmon: (lm75) Improve error handling Date: Tue, 26 Jul 2016 08:19:46 -0700 Message-Id: <1469546388-29907-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1469546388-29907-1-git-send-email-linux@roeck-us.net> References: <1469546388-29907-1-git-send-email-linux@roeck-us.net> 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 Use devm_add_action_or_reset() instead of devm_add_action(), and check its return value. Signed-off-by: Guenter Roeck --- drivers/hwmon/lm75.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 547a9c87c68c..92f9d4bbf597 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -220,7 +220,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) struct device *dev = &client->dev; struct device *hwmon_dev; struct lm75_data *data; - int status; + int status, err; u8 set_mask, clr_mask; int new; enum lm75_type kind = id->driver_data; @@ -331,7 +331,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) if (status != new) i2c_smbus_write_byte_data(client, LM75_REG_CONF, new); - devm_add_action(dev, lm75_remove, data); + err = devm_add_action_or_reset(dev, lm75_remove, data); + if (err) + return err; dev_dbg(dev, "Config %02x\n", new);