Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6293113pxb; Mon, 8 Nov 2021 06:23:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxueXQhjkWGVh1ZGklhyNdJLeHsbpjRK2Y6s0MCGipFQ2Yj75Ne2+PLdUL308moWze1N0MZ X-Received: by 2002:a05:6402:4388:: with SMTP id o8mr9797edc.342.1636381414226; Mon, 08 Nov 2021 06:23:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636381414; cv=none; d=google.com; s=arc-20160816; b=XKF+xIVpUhHR4nl4LttEpVSB1nX6yHiHlcf9D84L8xhJdue5CLCa8agptY8Bt1NuNE vjtvONzICWJi+96K1gTWu1vKgQw2l00GzJvPEXUjfaKVq0TSKcJvM+MOVbvDnQijJ6PE Yp0n7Tohwu8wCSrIj/2/ZWofcDT/5Wjmknf2xai0uIYuqTZ1XQGKtd/4VfM7g3NV4mP7 wvret8XiNROmbKZhD/9j1fkmrhDMDN7kJgX+KUPi/PCep06BBtDf8S4/34BC/qdPFUpf FyVE6ou+TmCjRLgQgF3tccifSN36uYwhOuPNp+5ZYcQD4f6DeSfXD4o5vWN7LQH6h5wu MkaA== 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=ylqDbxsbeGt4jJrQOrHP0W5dDr2VwFt1eu+TTFpHEK4=; b=Fw+HJSuHwEbMeXqbmCQkV05bizqaMtmQxVma8uxpD8UUD083OeDVid6OdtVeCqMr1o Tm9N5OrT3DMmMfrx4/gLyMEgVSiQEe5AZIRIYgLjimCLXZqEvNwYb9YHjStAdzStqPoE C1yGWbX6SL4VsPvvvkW1gl9n1EAWW3g+cDyM0JJ61tOx0mCK+R+bvPAwJw+hB8sIMZI2 akTOxaHZ49ywB7LdkXQvUFdJm4ySd0UAoMSznPZitYH1n5M8YqIaJDm17WvaJZTvqPjA 0jVRPRMLOpqPdeFIWjuom6/+F15N0we6masJfc8YOjKpp5fwHVmboeWRukXnMAUGFheV 4G2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ov/ebkmg"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si14898692edb.321.2021.11.08.06.23.02; Mon, 08 Nov 2021 06:23:34 -0800 (PST) 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=20210112 header.b="ov/ebkmg"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239350AbhKHMBa (ORCPT + 99 others); Mon, 8 Nov 2021 07:01:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbhKHMB3 (ORCPT ); Mon, 8 Nov 2021 07:01:29 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 845B5C061570 for ; Mon, 8 Nov 2021 03:58:45 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id z26so1341805iod.10 for ; Mon, 08 Nov 2021 03:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ylqDbxsbeGt4jJrQOrHP0W5dDr2VwFt1eu+TTFpHEK4=; b=ov/ebkmg26IvR4AYTe4quYd79E/Pd15OnFP7fNG08x461C419GBUTV7YM7OTnbC2kS f0MKJIVW6l3OUFrPLvQcJ31Ldi86adpVnCsEchds5wlRqt0psuZ0V+ubNuE7lGDvw3gd cDX9R+DFJiU3nVtidQ89v9ap0Csa131gG4XWEol+BVFtgbg1ljDMg3jmi2hLePMlmnX+ CetYe4SrsEbhTgHjh1D66Lnm4g4JGyjXhS1TnhudWBt5hk7qxRpxhxQ2WxT5CTbhdT5t 6uVpi9WSWRAL47gszWflN8mGAedYC6i0kHwfLKIh8nv+Fa1cieR7dAUF4GbXToa7M/nI ClrA== 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=ylqDbxsbeGt4jJrQOrHP0W5dDr2VwFt1eu+TTFpHEK4=; b=xrH9fdCjzcTzF70Qo0tvbRs2yeUtu9xmJdVDq3mdzxROfwnMNabHuuksRqC/NcaN0f Nexd8HfDR69obT1s/yymlQ4gvx4xyHxYB8gqHRI7V6bVBjEwULFq7o8bi1dZLPVOv1ls gAiAYh25TgSS+zu9BRnitC1h0uxe2iKaMNvp5/8gTN5UrdjtBUp0OIUP8y8s8qGDzkIL mCzw1hFxAH3tNIU5eaH4RHch9Aik6WEg9cMNn6TveSb/k2MGOMLILTkiYBffL1FvVspX Fz0uR2o3mSweYwa0GK2Wr9B0wDlmFbW7fCLoCaGJ8rYVE0BVVfEpFliYU+0Xq+mq+iK7 5jxQ== X-Gm-Message-State: AOAM531CbUcNeXXpg8DWiHsaLL3kZLZiEHrQqZwq19d9iUb9gCu3IgS0 DH++gryQmfhArm2tFElH5h5E2M1bf5XUafNXraA= X-Received: by 2002:a05:6602:8ce:: with SMTP id h14mr2471749ioz.177.1636372725022; Mon, 08 Nov 2021 03:58:45 -0800 (PST) MIME-Version: 1.0 References: <20211107150304.3253-1-sampaio.ime@gmail.com> <20211107150304.3253-3-sampaio.ime@gmail.com> In-Reply-To: <20211107150304.3253-3-sampaio.ime@gmail.com> From: Miguel Ojeda Date: Mon, 8 Nov 2021 12:58:33 +0100 Message-ID: Subject: Re: [PATCH 2/2] auxdisplay: charlcd: checking for pointer reference before dereferencing To: Luiz Sampaio Cc: Miguel Ojeda , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 7, 2021 at 4:03 PM Luiz Sampaio wrote: > > Check if the pointer lcd->ops->init_display exists before dereferencing it. > If a driver called charlcd_init() without defining the ops, this would > return segmentation fault, as happened to me when implementing a charlcd > driver. Checking the pointer before dereferencing protects from > segmentation fault. It can't hurt -- thanks! I think `EINVAL` makes more sense here, also we could use `WARN_ON`: if (WARN_ON(!lcd->ops->init_display)) return -EINVAL; Cheers, Miguel