Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1653301rwd; Mon, 15 May 2023 00:41:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67OxcA4/bkiGnzPmW6ZpSWrFAsC3W/qGeOAjY5MmWLoYIFlqt04kAlSLJsLAU+u8h4BFb6 X-Received: by 2002:a17:90a:5581:b0:24d:f159:d28b with SMTP id c1-20020a17090a558100b0024df159d28bmr32354003pji.47.1684136515512; Mon, 15 May 2023 00:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684136515; cv=none; d=google.com; s=arc-20160816; b=OnjT6DPiT2ag7Zx3wA/5Gkzk4CEyQ3DzmCvbV+c7cA/n82P8QvAVsejYxAY/Q1WOzU Q56PyaHqvI71zXjzQHXuPb8eHLPFXqoI8gLfIfL/XPwgVU/sNbP/yMcAjRjVTXLJmU8Q A1X6nhQgh8u9IeQzdSl5sBq0GjRD22/cL5wj869s/NEHotmv2XK+f4TW2oCxJ1LKKoMn jVlMVBXSlAQTwEJeqCo/VODmvnq6YPrl20KfXQJl/GSJNG6HmBHp4kVC0aYA1nLCUeAY 40mgoZhKuVnkPtsRo5/lVfnLaKEfa7C7WwkhDRNqn0l7bwXOU8UMpauoIsI7d4CpkS0n g93g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eurMz9NQAUmkORq8ZJu1AgnEBQF8a6B21GIn/UfxOEI=; b=FxR1dqWp6HB0b+sZR3AAWB9Mwou0/sDeg3Vc8V41pBEJlwJrIuujv5HfqJoDZCPxft nWxPFN91P/rMMDLcOMKcFdh9iOlchY8Sab3qZ5ZUifP365BOu2wVm92Ougem0BaBSNhK T7EsgHSINulSYKXjb2jaJno9sr6PI6A9r/e7erblEffuoNX9UwHnvEEWyaS2iIuSG0bl 9WfCvb4EaoD25IlCTi2ZLpmkjnYdEfTA4uTo7xR//U/n61IVQ+cxKjsxfCa6kUG60q0o UfqNIU9ntM0mNoTaEBH+cnuYlUkqK3Z1/AEgI60/Gpmtji1CatQW9w/hffGAhoPwlPcb d3FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=URaTzQG6; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a637b07000000b00530b894c135si4532974pgc.270.2023.05.15.00.41.40; Mon, 15 May 2023 00:41:55 -0700 (PDT) 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=@linaro.org header.s=google header.b=URaTzQG6; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235175AbjEOH0I (ORCPT + 99 others); Mon, 15 May 2023 03:26:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233775AbjEOH0H (ORCPT ); Mon, 15 May 2023 03:26:07 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF8FD1AB for ; Mon, 15 May 2023 00:26:05 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-559debdedb5so184910817b3.0 for ; Mon, 15 May 2023 00:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684135565; x=1686727565; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eurMz9NQAUmkORq8ZJu1AgnEBQF8a6B21GIn/UfxOEI=; b=URaTzQG6g74E8biL/yJ5/3corUdz5kezIBq8rpkzGX9Lj4RGuyYIwzggM9i3yP/toH TWT9U3hF7A5kDzqL7CrTnM/e7/2qSclroVT1O3JKPjx7eN4O5ztR9SOnKNGgBL5Cn4M6 720A5c4RLjqxkCe3SZVi5906Lc8023qjsuk5lOVoHtFJSXve5zsQJzmXLGyvan3hAPm1 G1al3fa/jAL177yGkpoqGNHpVi7sQU4O7k2+H27pTjFvlPdBZmpTazg3BgZ/CJZoeMDS Fv7wmuUNmcTEF5WEpzg8QfroJgQjdjl4XCtW1xdXcM5sNDw2Go4KZqLhavnSlv4laa8W iwug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684135565; x=1686727565; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eurMz9NQAUmkORq8ZJu1AgnEBQF8a6B21GIn/UfxOEI=; b=PbFJhpFtsuXZHNvu+ed5QwwUZf4NYEdLDuiWeSPwoo57YDyYAjM9JlxdJzKlM50SgJ hnBzirpXQbkAtmsEW6OU+qtUwvPPEWxR5AL5LLKaM45HncopnxXHvJlnmD/tU1WRiqdA dzz2qx2Di7uT2CkMNjjSmGLnHGL+NXxv0ACOgdoRKtcQf+CROYmvtvPMSCPn0B4PRkuD qpVY2Z5oZQZZYrKQtyesjzeiaFOMLncHpozoqwnl6Fe3Ctcipl9lnxccxlwmQ+hEFcjX dbIn4YZCtUixFdU1CSUEaij3Qx0OAqQRPwWBSRK9auSxuCdwDjLuayB6rTNlM79mOu8i 1ztQ== X-Gm-Message-State: AC+VfDwx+JSTIzYnXYpbM6qa/F+2vM4ApE61Wmr+TFnURk/7FIU9vJwh WV97tTIYfYt2ynKUEFW/Zpjk5+YCd0ajqFf1F4p7WQ== X-Received: by 2002:a0d:fc44:0:b0:555:d983:f4f0 with SMTP id m65-20020a0dfc44000000b00555d983f4f0mr28247355ywf.24.1684135564884; Mon, 15 May 2023 00:26:04 -0700 (PDT) MIME-Version: 1.0 References: <202304232146.7M89pwCz-lkp@intel.com> In-Reply-To: From: Linus Walleij Date: Mon, 15 May 2023 09:25:53 +0200 Message-ID: Subject: Re: [PATCH v2] gpio: gpiolib: clear the array_info's memory space To: Yan Wang Cc: brgl@bgdev.pl, "open list:GPIO SUBSYSTEM" , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 > @@ -4359,6 +4359,8 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev, > * hardware number is different from its array index. > */ > if (bitmap_full(array_info->get_mask, descs->ndescs)) { > + /*clear descs->info*/ > + memset(array_info, 0, sizeof(struct gpio_array)); > array_info = NULL; This is not the right solution. The array_info points beyond descs and descs have be krealloc:ed to fit the array info. The right solution is not to fill that memory with zeroes, but to krealloc back to the size that descs had before we did this resizing to begin with. Possibly the condition should be detected *before* we start to krealloc() so we can avoid all the krealloc():ing. If the actual issue cannot be fixed I think it is no better or worse to just leave the code as it is, we are just zeroing some unused memory. Yours, Linus Walleij