Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp1719038rwb; Sun, 4 Sep 2022 00:18:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR7XhxxJxPW97U42cIuDh3gIsUQ+2q+L2hxY/rm5HtO5dtSGN/GGlBNbMpKE9RZGtjZV9F/j X-Received: by 2002:a63:6948:0:b0:433:5e5b:54b2 with SMTP id e69-20020a636948000000b004335e5b54b2mr6530531pgc.286.1662275898919; Sun, 04 Sep 2022 00:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662275898; cv=none; d=google.com; s=arc-20160816; b=kXj8wnjCcWy9U0i6QVoEy3H5qTVy2c5iIcwrcGkEmmTClRke+6FJraZdj490AM1URr ASF88xfeGoPTX5TmBtk/3xCbvoUh4UIn8VszEW5Hao1uu55g3xR9n+i5Y96abaz+1G9g EDqLLJ9PgjSEs6lvDoLcQ11xUZo6VXneSR57uk7C7fPTGASBGmExAsWBOdmUgcFrFLuN 8qmJ9qzhNEcQsxNJf247P5DDs45gytahcYW3tcPkEBHaDXNc/JDgm1SIbNz3EB2yU1Pb P1VZ6OkGn99QCGpXzlxF6e9XNrIvJpK1XN27rzXk4Ax6cZ6rYSrDoeg8kViZHvaxae3k aphQ== 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:dkim-signature; bh=MkjINlMSIrFJago9TGoXCptVDuGA59OpmcEi0DZDuak=; b=Yuk/lrJx3TaAz96R3cszkMnwVuys+OgLw22nZ8uZ/lXrBtjxucaBYwzqIRqGRwcg8W ra2t/IamdVsYLfBsC6jDbYdY44riXAiBneDpz2mEXi8Tko9h8KCJOedcR3trld+1ojyH eoU9St689g/kgdRQo96i2AgY96ZgJkaOUJu3M9GTlpdXiF0WyzFSoT17fmfoOM6uiwMX rIaprKfOFi159D0tn3+m4LFm3BPfXiVYblEal9Tk8XYD/q1SoKxiQruE489vtQQhi8+K SAcoRagvL6Ef9WsqWPVRcEdnYKTlW8IRCtvro8jycGFvAvqRZvUQioG6aYcuvWLc4zb4 DUGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wo0z3G9b; 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 b9-20020a17090a9bc900b001fb5b114e73si6640510pjw.151.2022.09.04.00.17.47; Sun, 04 Sep 2022 00:18:18 -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=@linuxfoundation.org header.s=korg header.b=wo0z3G9b; 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 S232159AbiIDGVF (ORCPT + 99 others); Sun, 4 Sep 2022 02:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232351AbiIDGVB (ORCPT ); Sun, 4 Sep 2022 02:21:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE8C632EF6 for ; Sat, 3 Sep 2022 23:21:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A3E8BB80D0D for ; Sun, 4 Sep 2022 06:20:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D99D6C433C1; Sun, 4 Sep 2022 06:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662272458; bh=AUNJxKjdpBWg6fMDQFF0bVqggoWCYu/JuIcn4fiRQ60=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wo0z3G9bwRMsmoM5Z6MUT6mtZ3TFYgX1H26++Y+OcS5nm2k5sMRb4m3D7TBo1y8sB 9XhllBtG05bt2F+zkckiW4FRjc+wAQi+uVbU1VRGCxaY7II8IZWZfmlDH6W8GidR22 /B2EPQkMctBWx8w/fx7NYohqnVmjZwCkJxiaOfpY= Date: Sun, 4 Sep 2022 08:20:55 +0200 From: Greg KH To: Li Zhong Cc: linux-kernel@vger.kernel.org, rafael@kernel.org Subject: Re: [PATCH v2] drivers/base/auxiliary: check return value of strrchr() Message-ID: References: <20220904005156.2281982-1-floridsleeves@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220904005156.2281982-1-floridsleeves@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Sat, Sep 03, 2022 at 05:51:56PM -0700, Li Zhong wrote: > The return value of strrchr() could be NULL, which will cause invalid > offset in (int)(p - name). So we check it here. > > Signed-off-by: Li Zhong > --- > drivers/base/auxiliary.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c > index 8c5e65930617..2ec0306bfba3 100644 > --- a/drivers/base/auxiliary.c > +++ b/drivers/base/auxiliary.c > @@ -191,6 +191,8 @@ static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env *env) > > name = dev_name(dev); > p = strrchr(name, '.'); > + if (!p) > + return -EINVAL; How can that ever happen? For what device will that be triggered? And again, please follow Documentation/process/researcher-guidelines.rst