<html><head></head><body><div id="editor_version_1.35.4_IdkxA2Ph" style="word-break:break-word;"><div data-zone-id="0" data-line-index="0" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">Hi, Ville & all</div><div data-zone-id="0" data-line-index="1" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">Thanks for quick reply!</div><div data-zone-id="0" data-line-index="2" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">According to your reply, the *info has been checked info earlier, and I have read the code of framebuffer_check() and related drm_get_format_info() which it calls, but unfortunatelly, I haven't seen judgement(check) for it. What I only found related with check is the sentence below (in *drm_format_info() in drivers/gpu/drm/drm_fourcc.c):</div><div data-zone-id="0" data-line-index="3" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">```</div><div data-zone-id="0" data-line-index="4" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">info = __drm_format_info(format);</div><div data-zone-id="0" data-line-index="5" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">WARN_ON(!info);</div><div data-zone-id="0" data-line-index="6" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">``` </div><div data-zone-id="0" data-line-index="7" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">But to the best of my knowledge, "WARN_ON" only gives a dump_stack(), not discontinue the program going on, so it will indeed go to the below line in framebuffer_check() and raise an error:</div><div data-zone-id="0" data-line-index="8" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">```</div><div data-zone-id="0" data-line-index="9" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">for (i = 0; i < info->num_planes; i++) {</div><div data-zone-id="0" data-line-index="10" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">```</div><div data-zone-id="0" data-line-index="11" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">So maybe it will make sense of my commited code.</div><div data-zone-id="0" data-line-index="12" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;"><br/></div><div data-zone-id="0" data-line-index="13" data-line="true" style="font-size: 14px; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">Looking forward to your reply and guidance.</div></div><div class="history-quote-wrapper" id="lark-mail-quote-169865692"><div style="list-style-position: inside" data-mail-html-ignore="" data-html-block="quote"><div class="adit-html-block adit-html-block--collapsed" style="border-left: none; padding-left: 0px;"><div><div class="adit-html-block__attr history-quote-meta-wrapper history-quote-gap-tag" id="lark-mail-meta-iluJYQH3A" style="padding: 12px; background: rgb(245, 246, 247); color: rgb(31, 35, 41); border-radius: 4px; margin-top: 24px; margin-bottom: 12px;"><div id="lark-mail-quote-be3d56183c0dd58949effcdf7fab0549"><div style="word-break: break-word;"><div style=""><span style="white-space:nowrap;">From: </span><span style="white-space: nowrap;">"Ville Syrjälä"<<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:ville.syrjala@linux.intel.com" class="quote-head-meta-mailto" data-mailto="mailto:ville.syrjala@linux.intel.com">ville.syrjala@linux.intel.com</a>></span></div><div style=""><span style="white-space:nowrap;">Date: </span> Fri, Oct 27, 2023, 20:33</div><div style=""><span style="white-space:nowrap;">Subject: </span> Re: [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().</div><div style=""><span style="white-space:nowrap;">To: </span><span style="white-space: nowrap;">"Peng Hao"<<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:penghao@dingdao.com" class="quote-head-meta-mailto" data-mailto="mailto:penghao@dingdao.com">penghao@dingdao.com</a>></span></div><div style=""><span style="white-space:nowrap;">Cc: </span><span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:maarten.lankhorst@linux.intel.com" class="quote-head-meta-mailto" data-mailto="mailto:maarten.lankhorst@linux.intel.com">maarten.lankhorst@linux.intel.com</a>></span>, <span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:mripard@kernel.org" class="quote-head-meta-mailto" data-mailto="mailto:mripard@kernel.org">mripard@kernel.org</a>></span>, <span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:tzimmermann@suse.de" class="quote-head-meta-mailto" data-mailto="mailto:tzimmermann@suse.de">tzimmermann@suse.de</a>></span>, <span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:airlied@gmail.com" class="quote-head-meta-mailto" data-mailto="mailto:airlied@gmail.com">airlied@gmail.com</a>></span>, <span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:daniel@ffwll.ch" class="quote-head-meta-mailto" data-mailto="mailto:daniel@ffwll.ch">daniel@ffwll.ch</a>></span>, <span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:linux-kernel@vger.kernel.org" class="quote-head-meta-mailto" data-mailto="mailto:linux-kernel@vger.kernel.org">linux-kernel@vger.kernel.org</a>></span>, <span style="white-space: nowrap;"><<a style="overflow-wrap: break-word; white-space: pre-wrap; hyphens: none; word-break: break-word; cursor: pointer; text-decoration: none; color: inherit;" href="mailto:dri-devel@lists.freedesktop.org" class="quote-head-meta-mailto" data-mailto="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>></span></div></div></div></div><div><div data-type="plainText" style="white-space: pre-wrap"><span>On Fri, Oct 27, 2023 at 05:19:12PM +0800, Peng Hao wrote:
> Since drm_get_format_info() may return NULL,
Not in this case since we already checked it earlier.
> so a judgement of return
> value is needed to add.
>
> Signed-off-by: Peng Hao <<a href="mailto:penghao@dingdao.com" target="_blank" ref="noopener noreferrer">penghao@dingdao.com</a>>
> ---
> drivers/gpu/drm/drm_framebuffer.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index aff3746dedfb..be7dd1998c04 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
>
> /* now let the driver pick its own format info */
> info = drm_get_format_info(dev, r);
> + if (!info) {
> + drm_dbg_kms(dev, "no matched format info\n");
> + return -EFAULT;
> + }
>
> for (i = 0; i < info->num_planes; i++) {
> unsigned int width = fb_plane_width(r->width, info, i);
> --
> 2.37.1
--
Ville Syrjälä
Intel</span></div></div></div></div></div></div></body></html>