Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6434844rwb; Tue, 22 Nov 2022 13:22:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7TtVCVgtjPDwaaVhas3JJoX+GPsgQBlFgpyvqur6FtdcPfWYMbJjcxeosyUohTWFR1ZZmJ X-Received: by 2002:a17:906:81cd:b0:7ad:beb3:91b6 with SMTP id e13-20020a17090681cd00b007adbeb391b6mr5910112ejx.159.1669152154817; Tue, 22 Nov 2022 13:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669152154; cv=none; d=google.com; s=arc-20160816; b=VcsMI0+IWb/vM2yXrERyv88KX9x3ybO3+9LkhX4CwaSXoaNoZf19o0xN+03MY/yI+b HwUyoVokJ5hkbe8qZZU0yBETfiayxf4Am5EK2h+xS7wqiQK+F0B1laW4AO0X8zI/lMiv v6qyY11BRP6+YjRpONKV06wo+Mj4GEk+6ShYKh41f6bZWAonEZUndcAoxanNVhdj0dzz VuvKAfnFTGIovaAEso0bxiNaG6IG+Ut7SYyOsC8O+5lkvSAmo/vJyVFmCwu2PsgJRMob WzmRmTN8I3AMqL7oxpUs7Rr6mym/QMm9s0epVk2XQsBSM3mlZjkk0DUbrGNq9cCWQLUV x/0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mUfAXXISs8sZj+gKsrx2+PPqyWsFBSmyByYJxrMQRCU=; b=oCZ/KNfSmkXYiksiqOQRL2uflbf0/3AgTKAfN1fSsacbd+O0UQFJLmgqLSZC2fLWRd MWayg0P/yCypzAdXJ5mhO5bod13ZKLkLSluEJF2LXEEAqxQlHB52NyY02TLGJvQwxLZs tw3teeUVSFhJjcGuDMHrSMM0g18QmvIioUb/CLlRzMOjEh3swdoWwkiNgrc5qWtPGbW3 /2I4k/2nYeKffb0s2GsUhS0xrPCss5KvS33rCxLC9xZ5aBeJBN6i1dgP1BQOd3cHAUIk 88arKuQqg7GiEHizvwC5GCAgna7X5eA+DqwAhUOsAd2vvBxos1Ft5phrDDMgW3pwc8x1 JcqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=Ly4CWsMp; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a056402441400b004587e99bcc2si10823125eda.383.2022.11.22.13.22.12; Tue, 22 Nov 2022 13:22:34 -0800 (PST) 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=@linuxfoundation.org header.s=google header.b=Ly4CWsMp; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234930AbiKVUsw (ORCPT + 89 others); Tue, 22 Nov 2022 15:48:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234704AbiKVUsm (ORCPT ); Tue, 22 Nov 2022 15:48:42 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53FD5100A for ; Tue, 22 Nov 2022 12:48:41 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id z3so11852148iof.3 for ; Tue, 22 Nov 2022 12:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mUfAXXISs8sZj+gKsrx2+PPqyWsFBSmyByYJxrMQRCU=; b=Ly4CWsMpbetOsjGtfHoSI0AyJt/j+cgj7TU0CcWHFhWhUeAbyeBHnRkPWg/N8XpH5R QSdaA80i5qtZF9GUb4SzyidBnsUa7EDJHGzTS9oz1atz5kKSfd1XRbvkAl2UPS7GJOvR dBaAaSk3Qi9erRayCgEH8yA9ZYKeNkhF8/SjA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mUfAXXISs8sZj+gKsrx2+PPqyWsFBSmyByYJxrMQRCU=; b=ZXiBORL+NH/HX7AFqVI74qe5kddhc+DquTjRLr/IA9xg7qAZo8aNqteXLVXptzJD3N Uz0uNHL1ka7jg1fsQWPw3ZQFeooaw14U+JUeswsfTayOoedKjhAF8XyMjgnDf4DL3N3W By78x+1eh3V/ysbE+xiUh0RNOe0hBdBVL3H1q2434xiXCCsXwLwaTylcUqVuobir7+aj uuX913GXLcifrilsekmU3PXak7+OsaGn61GtkSpr+a9levors0m8Kqei2TGItMOId24d f30hRbJl9hE2nvCHL+BOFWcqlVQMd4FJepiCeqeKT0aNBU3cfQ0CMqkQBWqk/xqJD+k2 7Etg== X-Gm-Message-State: ANoB5pnV5sZTxJkDBVtXjbea6lOC6MUCvOti9Qou8KSnUsVIJo4XHy35 jSJMhGSjOPDZ9dcen3TKPUgmtGfKYdpmqg== X-Received: by 2002:a05:6602:200c:b0:6de:90a6:6b04 with SMTP id y12-20020a056602200c00b006de90a66b04mr9899854iod.101.1669150120581; Tue, 22 Nov 2022 12:48:40 -0800 (PST) Received: from shuah-tx13.internal ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id s16-20020a92cc10000000b00302b5d0d07asm1948431ilp.17.2022.11.22.12.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:48:39 -0800 (PST) From: Shuah Khan To: pavel@ucw.cz Cc: Shuah Khan , patches@opensource.cirrus.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] leds: leds-wm831x-status: init chip_pdata before access Date: Tue, 22 Nov 2022 13:48:37 -0700 Message-Id: <20221122204837.11611-1-skhan@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 wm831x_status_probe() accesses status from chip_pdata before initializing it. Fix it. Signed-off-by: Shuah Khan --- drivers/leds/leds-wm831x-status.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c index c48b80574f02..5060c83f3b25 100644 --- a/drivers/leds/leds-wm831x-status.c +++ b/drivers/leds/leds-wm831x-status.c @@ -212,7 +212,7 @@ static int wm831x_status_probe(struct platform_device *pdev) struct wm831x_status_pdata pdata; struct wm831x_status *drvdata; struct resource *res; - int id = pdev->id % ARRAY_SIZE(chip_pdata->status); + int id; int ret; res = platform_get_resource(pdev, IORESOURCE_REG, 0); @@ -229,9 +229,10 @@ static int wm831x_status_probe(struct platform_device *pdev) drvdata->wm831x = wm831x; drvdata->reg = res->start; - if (dev_get_platdata(wm831x->dev)) + if (dev_get_platdata(wm831x->dev)) { chip_pdata = dev_get_platdata(wm831x->dev); - else + id = pdev->id % ARRAY_SIZE(chip_pdata->status); + } else chip_pdata = NULL; memset(&pdata, 0, sizeof(pdata)); -- 2.34.1