From patchwork Fri Dec 21 07:25:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10739983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 578C213A4 for ; Fri, 21 Dec 2018 07:25:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3869028714 for ; Fri, 21 Dec 2018 07:25:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C94528735; Fri, 21 Dec 2018 07:25:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 C5CAA28714 for ; Fri, 21 Dec 2018 07:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732408AbeLUHZr (ORCPT ); Fri, 21 Dec 2018 02:25:47 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:60850 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731930AbeLUHZr (ORCPT ); Fri, 21 Dec 2018 02:25:47 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 0D1ECCDA for ; Fri, 21 Dec 2018 07:25:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8wPLtpQnln0c for ; Fri, 21 Dec 2018 01:25:45 -0600 (CST) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id D085BCD4 for ; Fri, 21 Dec 2018 01:25:45 -0600 (CST) Received: by mail-io1-f69.google.com with SMTP id t133so3572711iof.20 for ; Thu, 20 Dec 2018 23:25:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=jipBkokQTPzDdu0P3LVe5/zRG7nUwlvyAUInrUQ280A=; b=pI2VddK519c6ZpzEN0K99Ah9n/bbwQ6jPCB+KzAB+ouZOOctYxdlXwgSuOky5EKNll cxqRKiZj8HXUFC2Sp+QypYjBWD+Vko2CCr4BEtD+Qwe5RN6wiVfHjesQsb9QaJkM03SE jF9DC4eC2OrFJZauoe5AKBK86BWJrMIRNfbE3FfIDP9F4Y9hiqEsF88yJ9Zr7cDVW/oe t8+hxvusBmTNMoONALXj/4GhZYgby/R+uPajr1X69pBUd8rzc3eUnzNZa/bXeLNCUwtY tQ0P5Q2gO3eqzhHeLppUjW1iKeNePYjK9tWs/MDwwPL0N1Iy6oDdtSFoD04xO38LIW9W Qe2w== 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; bh=jipBkokQTPzDdu0P3LVe5/zRG7nUwlvyAUInrUQ280A=; b=SG2tlh1LEC9UCeQZTwgfsJdxd7EDdcCk1t415URmgytDNS72+Ow7Smm5p2nP4Idk7o xZbAiJMaLS6gfsY9AYSJVbd3lf67tyKnGBFS3QU6l8DrKSlem/cUnUprEgPzhB5faYI8 nP2jmKmEFmGRRIOcUEcN/Tx7Y0VAzxOEpFFNFMd7w79MiWMMD3ajdGYEP4+NHsCyzzEH RWinWiE1rXJwS3Ef/OgIRM8BJ4oGTkfiQfi7OJVlT5usVX+dpFmxQCw9KZbxNBsjApnm At1iNpAt+ktTQeip1SCNPOypXFfT0Qq3Quj74e9Pisj5fi3dO5mc23eWDKX3oUV7odKQ 13Bg== X-Gm-Message-State: AJcUukdu2myna7lnDWxxhYDwOWcm5wxhNThUvtcVXHC6PmIvDqHHXL+7 +3rF2SBy73IYfr6Oq+G+6g/KdJgOWNTVI9y9RWUVjrx/PvAiLqBEf1xEiMrcMEuKdI/yXYRmS69 3Pec/HbWxRs5gJhTiPHMOge/19Ws= X-Received: by 2002:a24:3752:: with SMTP id r79mr1038413itr.121.1545377145481; Thu, 20 Dec 2018 23:25:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/WNsTKNAZNlVTmfqbpRcQAze1z4uk/P9rkG5+FOjNjK4p2njXOirCjeQRtmS8YKNo3+Uxa85Q== X-Received: by 2002:a24:3752:: with SMTP id r79mr1038408itr.121.1545377145234; Thu, 20 Dec 2018 23:25:45 -0800 (PST) Received: from localhost.localdomain (host-173-230-104-23.mnmigsc.mn.minneapolis.us.clients.pavlovmedia.net. [173.230.104.23]) by smtp.gmail.com with ESMTPSA id 81sm8537907itz.15.2018.12.20.23.25.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 23:25:44 -0800 (PST) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] lm80: fix a missing check of return value Date: Fri, 21 Dec 2018 01:25:24 -0600 Message-Id: <20181221072524.60369-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.2 (Apple Git-113) 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 When lm80_read_value() fails, the read data is an error number. So let's check its status before using the read data. Signed-off-by: Kangjie Lu --- drivers/hwmon/lm80.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index fca6363cd77f..7457ff8bc860 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -628,6 +628,7 @@ static int lm80_probe(struct i2c_client *client, struct device *dev = &client->dev; struct device *hwmon_dev; struct lm80_data *data; + int rv; data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL); if (!data) @@ -640,8 +641,14 @@ static int lm80_probe(struct i2c_client *client, lm80_init_client(client); /* A few vars need to be filled upon startup */ - data->fan[f_min][0] = lm80_read_value(client, LM80_REG_FAN_MIN(1)); - data->fan[f_min][1] = lm80_read_value(client, LM80_REG_FAN_MIN(2)); + rv = lm80_read_value(client, LM80_REG_FAN_MIN(1)); + if (rv < 0) + return rv; + data->fan[f_min][0] = rv; + rv = lm80_read_value(client, LM80_REG_FAN_MIN(2)); + if (rv < 0) + return rv; + data->fan[f_min][1] = rv; hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, data, lm80_groups);