Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2692108iof; Wed, 8 Jun 2022 10:02:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydHVDgiOsR18JeTe54mbRM023L7Af5d1XFKrUKT4FEOXAC2nWfABMvn6KHenA/vNwgrHsJ X-Received: by 2002:a63:2482:0:b0:3fc:55e3:1410 with SMTP id k124-20020a632482000000b003fc55e31410mr32097734pgk.583.1654707743678; Wed, 08 Jun 2022 10:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654707743; cv=none; d=google.com; s=arc-20160816; b=HD27lIvJ+Hh8c/HehFzSy5PYNyOfrr3TOMkmMLifP6jf1E7gifeBFnSksm1w/Y2cd8 NWsdGawxQkATagGvMOHmphFcWv0zD/0YBlTrGZXDWsMYvT85pbALKVFsOcIZhcYSwgxC GxnbZAie7Y4hP0RBEjg+L1FdDfuNkCchA9ErHAE4oskFJsCvTIq/QSru27gGwCwZFY8n p6G+X2P7UFoCE5WJSBTPFvknXmCDvvZ/E8yCRr0Sb/0D7xqReX64PQw3dlBXDUp6V92C kQ5V/RrM6XDXMiV2O5pIf8I9Ep5CYpFH/5r+ajjhOgpG+YqEU1vnv6zbxFLil69zIg4f K5fQ== 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=5LOrhUovmaXW0suEK++cbwhUK+zWv0DfKlBlUwAV4lo=; b=oJ0K92E2XvlKQ39hp+NzSYtJeiW2ENY9zr1u2GbEIjdBmn1ic2GHSAu4F/c4sEBYzM qDI8gB2luDSa0zF+TkJIVxEAGPSFMQUG1o/HCRL86HpXa4iYp8MSQEvENu0umz5oJiW2 jeuvoDDn6SmpwTN0aOT1+1af0DOpCCTKz3MJ0G1TIFO0oHqMyVD+IZ8XmfRpijF4jkvE kC3Wxhg6zkhVVpbaAg+dOr+giifSoWPvPaaOqhNVmGG+jxcUonjQ0h1phvERXtr2C3Te 4teN7HVGKVeFI8g8jfwZF6DlzGaSVrIgqw25piTwa8YDVVdSvuyXbefkTfu9jj9cAKsg M8eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qYqOefA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oj17-20020a17090b4d9100b001df6ce033fasi34401968pjb.57.2022.06.08.10.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 10:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qYqOefA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B90DB2DABC9; Wed, 8 Jun 2022 09:32:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245715AbiFHQbn (ORCPT + 99 others); Wed, 8 Jun 2022 12:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiFHQbf (ORCPT ); Wed, 8 Jun 2022 12:31:35 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF5EA271460 for ; Wed, 8 Jun 2022 09:30:32 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 25so27556527edw.8 for ; Wed, 08 Jun 2022 09:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5LOrhUovmaXW0suEK++cbwhUK+zWv0DfKlBlUwAV4lo=; b=qYqOefA9OScbwUmWnO/BEh0VDQeePTDaCToVY2urQCiAvHu9sZEiQjL0YthhKgOYGS 3dJmrcyo0vMgf0UKjbjh80XGcUItQIPbTGBDDUm28eqUhq70+tNp5TDESRDUGoacMAMX 2K5hLE8pcV9r+dufkNka+Ddt4bdCaxUTq2bZ7YNCuDzfgRZuv/SWkDbRx0PYx7fS9/XG cOD7w+avBg7n8JNzFWBnjDfAjCgkT0jmvJEldObj4OiSnPLeeYTpiGKY1sjBnSJg2jx2 WOZAbWsDqsMB6Re/ge4p7ditTPeHtm1xzF8V3l+8v5mq3xejXena1B+ldtTOocAoMEAG AEDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5LOrhUovmaXW0suEK++cbwhUK+zWv0DfKlBlUwAV4lo=; b=7Z79LRg6+qEKpCDzHtVkKVRb4Tg20HEKPmIzvNKpv2N5VKB6Lf9eL9qLyU+yb8y3Yi DVJcDkrXlTN5ETqDAp/TkUWoxIx2u7NHNL3eaZTzff/rOhWmW1KDB2Yz4J2PYeQ49bNe IJ/IdWv111IVxujAQkiKJBhtsr6YXwWE8ZwEBBGrAmLEkka/RIujtqCZ1+GV0O1wpkuD xbsZ+/x8/HS4p/JAqm6BQW+UuP0Ql35l31uqwRnZNsgb5mY/y3vnXaq1Ea5XoEFOlWaw RfYhfOBdIGkFbK1nZ3VDwyPAtmDF2G7Zrt9rYkGxYyLFpdfqsNrlVy/I9xdVWBKl/2yo txxw== X-Gm-Message-State: AOAM533MSTpz55eo6vkscgv7eejv5B3mRS40mPX7kcBTCs0y1wxGBY1j y4omR6SoVcplrKlEq0HH0r8u8YkwPoRbtS7M6iBPkQ== X-Received: by 2002:a05:6402:2687:b0:430:328f:e46b with SMTP id w7-20020a056402268700b00430328fe46bmr2235466edd.33.1654705830946; Wed, 08 Jun 2022 09:30:30 -0700 (PDT) MIME-Version: 1.0 References: <20220608110734.2928245-1-tzungbi@kernel.org> <20220608110734.2928245-24-tzungbi@kernel.org> In-Reply-To: <20220608110734.2928245-24-tzungbi@kernel.org> From: Guenter Roeck Date: Wed, 8 Jun 2022 09:30:19 -0700 Message-ID: Subject: Re: [PATCH v3 23/23] platform/chrome: cros_ec_proto: handle empty payload in getting wake mask To: Tzung-Bi Shih Cc: Benson Leung , Guenter Roeck , "open list:CHROME HARDWARE PLATFORM SUPPORT" , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 On Wed, Jun 8, 2022 at 4:08 AM Tzung-Bi Shih wrote: > > cros_ec_get_host_event_wake_mask() expects to receive > sizeof(struct ec_response_host_event_mask) from send_command(). The > payload is valid only if the return value is positive. > > Return -EPROTO if send_command() returns 0 in > cros_ec_get_host_event_wake_mask(). > > Signed-off-by: Tzung-Bi Shih Reviewed-by: Guenter Roeck > --- > No v2. New and separated from the original series. > > drivers/platform/chrome/cros_ec_proto.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > index 68a411e84744..5cbaaba26ff7 100644 > --- a/drivers/platform/chrome/cros_ec_proto.c > +++ b/drivers/platform/chrome/cros_ec_proto.c > @@ -256,19 +256,23 @@ static int cros_ec_get_host_event_wake_mask(struct cros_ec_device *ec_dev, uint3 > msg->insize = sizeof(*r); > > ret = send_command(ec_dev, msg); > - if (ret >= 0) { > - mapped = cros_ec_map_error(msg->result); > - if (mapped) { > - ret = mapped; > - goto exit; > - } > + if (ret < 0) > + goto exit; > + > + mapped = cros_ec_map_error(msg->result); > + if (mapped) { > + ret = mapped; > + goto exit; > } > - if (ret > 0) { > - r = (struct ec_response_host_event_mask *)msg->data; > - *mask = r->mask; > - ret = 0; > + > + if (ret == 0) { > + ret = -EPROTO; > + goto exit; > } > > + r = (struct ec_response_host_event_mask *)msg->data; > + *mask = r->mask; > + ret = 0; > exit: > kfree(msg); > return ret; > -- > 2.36.1.255.ge46751e96f-goog >