Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4658771pxt; Wed, 11 Aug 2021 10:57:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFWRqCjBPolYKcsIG6/hpLRwJ0vCy95+yshYQgSxDoJJf5taQwapNZ+LcupyCnL6VFfQVm X-Received: by 2002:a92:d10d:: with SMTP id a13mr54110ilb.87.1628704633614; Wed, 11 Aug 2021 10:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628704633; cv=none; d=google.com; s=arc-20160816; b=nFEwEJsa73C0ugmehLiTmzpqtP1fm0ssFFCpEtj0i+UIyGzYIW4bthiq+0BuvJmLRm n189XvQf/8+XnI9FWS7obl48uEBnp2C+MaZYoNzeKpZIH/D+jnkpvs1D9CeBxqFlImUx 5eL5/adyBU0U8mGeQOav/mj9ggZtUvNMFANrMYooappwMb254/WxdmkX60vIi0NMQ1M6 uv9b136Or/0R8LW9mzClvMZSOShqN6bMFGmr6YLVwEzgxRyFPc1Jqh4saYu0WYnq9XAI NTXJCGPdO9VRGghM8rlUm20+PZw41gAGfASv2pc8ySTLz5Q8Ybssrvc58svGVBgPDV4P CVTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=lyYMz9VU8jhHpPHC9xSYBkshKOGS2weo/TTB2R2B10c=; b=EfrGn0+3bGlPf9TFgD38i+c+DKW4FxyuEi/N2x7QBM3/DBpvkg82IxKOFO8BnvHf4X eW0m1D4w5zihwzUzQGA0Wx4FaZxUWk9p6HqWwmgJezT7AAi8QJuiolhBfYw8J9PHs94E AEl3Ho26dPmleSghQTClIdMkZx+XKpR5cKKz5RwkboF2rJf+4OdYfqcxDw3CqFmPNinN ga3ROg1HFE8EfYXaiBwJ7Kv+Drnf8BWddA0tpx0hfFAJNMrKmJ8SadU1f3hIjsx/LaCi E/mAXUQqrlniW6RWVNwoeJPMEn3+4fruzgdOzN9z6b1c6tD93AiqBEwF4GWot//hE2OD 66ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fAP3m2EM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si9178980iow.93.2021.08.11.10.57.01; Wed, 11 Aug 2021 10:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fAP3m2EM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229781AbhHKRw2 (ORCPT + 99 others); Wed, 11 Aug 2021 13:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbhHKRw1 (ORCPT ); Wed, 11 Aug 2021 13:52:27 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9DF8C061765; Wed, 11 Aug 2021 10:52:03 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id a19so3311966qkg.2; Wed, 11 Aug 2021 10:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lyYMz9VU8jhHpPHC9xSYBkshKOGS2weo/TTB2R2B10c=; b=fAP3m2EMQqDx+Hp8c9T2UITQUIdKD2RoBs+vwB5N7F+5pKL7lZBh5+XC5HacAKNYtN FxnFx3NOdB0nuqH9TEEJefwaTR3SsIOv2pBGST3sTLsxDzcgJ7aC2TO3S7iz6emCu9GJ vTK77J3q9w4cMhgHA05C2LP7EbbbuOkmprFNydHvSnffZIdeMIhYBpoBBAuGYIL36FXa Lf77eo9pl/Dp/1ZVstRf9py2rLFtDgIJqMXYQHzJGdlbcrJxnngIk/DY1lclbwilO3S4 +d9+Eotpeket4SZOuj2Zkd7yS0gc/GEXIzZ9sTWnvWS+ISdb5kMY6humtmzb+307hQgR IsSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=lyYMz9VU8jhHpPHC9xSYBkshKOGS2weo/TTB2R2B10c=; b=Yas0TZw5sxIO1VHOHZD1p/+nQSjstJeQG2Erq8kfoDSOiQbPnTD3cAK04/hNyA2HYw GYFS+S2Pwrl7PwfWoK7TVsIeZkI3j4eLz5/cJFz5zr5AWtmcfJeDoAguCARumADFZKps amNQIkQLoHT7313P+ANxXpOZeXDcxNZU8PuaSiSLZ+s6slh0QbXH9MmFCM5rrM0M2rsb DhHosi50K9tL+d/dqtUWi5U2jZv/GdwA/E8Eta06ubezB8gnW7O+kt7LyU6Go/309TU9 q2UL8Hf1LzFpr1uIVDWH/1MLP3Yr+1mnaVaUjpJb+vHHD9XdnL8R+ZoLf8SwEch/WGBD cBpA== X-Gm-Message-State: AOAM532WI+IWrhkZM4tYwsyfFWo6cQ+jiWWf3Df3wp4iAirpJzxJRK1i 5POVMp6l0m74k+aHZHljmNWcuvmIN+U= X-Received: by 2002:a05:620a:c0c:: with SMTP id l12mr206532qki.318.1628704323032; Wed, 11 Aug 2021 10:52:03 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m16sm4728506qki.19.2021.08.11.10.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 10:51:51 -0700 (PDT) Sender: Guenter Roeck Date: Wed, 11 Aug 2021 10:51:20 -0700 From: Guenter Roeck To: Nadezda Lutovinova Cc: Marc Hulsman , Jean Delvare , Rudolf Marek , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: hwmon: Error handling in w83793.c, w83791d.c, w83792d.c Message-ID: <20210811175120.GA3138792@roeck-us.net> References: <20210811161515.17842-1-lutovinova@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210811161515.17842-1-lutovinova@ispras.ru> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 11, 2021 at 07:15:14PM +0300, Nadezda Lutovinova wrote: > In w83793_detect_subclients(): if driver read tmp value sufficient for > (tmp & 0x08) && (!(tmp & 0x80)) && ((tmp & 0x7) == ((tmp >> 4) & 0x7)) > from device then Null pointer dereference occurs. > (It is possible if tmp = 0b0xyz1xyz, where same chars mean same numbers). > > It can be fixed just by adding a checking for null pointer, patch for > this is in the next letter. But a question arised: > The array w83793_data->lm75 is used once in this function after switching > to devm_i2c_new_dummy_device() instead of i2c_new_dummy(). And this > function is called once (from w83793_probe()). Maybe this array should be > deleted from struct w83793_data? > That is part of it. However, the entire code is wrong. There is no need to check for I2C address overlap in the first place, and the i2c address for the second 'virtual' chip should start with 0x4c, not with 0x48. See w83793g/w83793ag datasheet, section 8.3.2.2. I assume the code was copied from w83791d and w83792d, where the addresses can indeed overlap. Guenter > The same situation in w83791d.c and in w83792d. > > Found by Linux Driver Verification project (linuxtesting.org). > > Signed-off-by: Nadezda Lutovinova